I used this simple general method for While, and it works great for application-based dialogs, however, I would like to have the same functionality in the sheet style dialog style, and it's hard for me to handle it.
According to the docs, as I understand them, the only inexhaustible approach from OS10.9 and higher is to use the NSAlert class with the completion handler process. It seems almost impossible to return Bool from a general-purpose method.
My code is:
-(BOOL)confirm :(NSString*)questionTitle withMoreInfo:(NSString*)addInfo andTheActionButtonTitle:(NSString*)actionType{
BOOL confirmFlag = NO;
NSAlert *alert = [NSAlert alertWithMessageText: questionTitle
defaultButton:actionType
alternateButton:@"Cancel"
otherButton:nil
informativeTextWithFormat:@"%@",addInfo];
[alert setAlertStyle:1];
NSInteger button = [alert runModal];
if(button == NSAlertDefaultReturn){
confirmFlag = YES;
}else{
confirmFlag = NO;
}
return confirmFlag;
}
The [alert runModal] returns the value I can return.
, [alert beginSheetModalForWindow: [self window] sheetWindow completeHandler: some_handler] . , , , .
, , , .
Mie