I'd like to learn to which class may a NSObject belong (other than NSAlert, NSOpenPanel and NSSavePanel) in order to be responsive to the above call (as in the question title). Here's the scenario of what I need to do. A menu-selected action which has to be modal for self.window requires additional user input in form of a dialog more elaborate than "OK/Cancel" (with the actual work-code omitted from example, for simplicity):
- (IBAction)myActionDialog:(id)sender
{
NSPanel *panel = self.myActionPanel;
[panel beginSheetModalForWindow:self.window completionHandler:^(NSInteger result) {
;
if (result == 0){
;
}
}];
}
However, the compiler warns:
'NSPanel may not respond to beginSheetModalForWindow:completionHandler'
which in fact proves to be true, yet I don't know how to get around this problem and code the desired behavior. I've been looking for proper documentation, but found nothing, so far. Any experienced advice is very welcome. Thanks in advance!
UPDATE:
This question respects the:
[[NSApplication sharedApplication] beginSheet: modalForWindow: modalDelegate: didEndSelector:
contextInfo: ]
method, which works with almost any subclass of NSPanel, AFAICT. The only problem is that Apple, while announcing it getting deprecated, hasn't yet properly documented a substitution method which would replace it universally, AFAIK.
Gestalt(gestaltSystemVersionMinor, &versionMinor);in- (void)applicationDidFinishLaunching:(NSNotification *)aNotification, then branching the code throughif(versionMinor > ...){...}else{...}. By the way, as of which version minor did the old API get retired for NSPanel (NSWindow) in general? I have 10.6 - 10.10, except for 10.9. Thanks in advance. - user3078414[NSWindow instancesRespondToSelector:@selector(beginSheet:completionHandler:)]instead of the gestalt check. Other better approaches include comparingNSAppKitVersionNumber; see AppKit release notes. - Ken Thomases-[NSApplication beginSheet:modalForWindow:modalDelegate:didEndSelector:contextInfo:], were officially deprecated in the 10.10 SDK. Just look up the method in the documentation and it tells you. - Ken Thomases