4

I'm learning some Objective-C/Cocoa and started to read up on handling open document events. Seems like the standard way is just via implementing application:openFile or application:openFiles in your NSApplicationDelegate.

So here's my little handler:

- (BOOL)application:(NSApplication *)sender openFile:(NSString *)filename {
    NSLog(@"Got open file! filename: %@", filename);
    return NO;
}

My question is: what does the boolean return value affect? This is not a document-based app, if that matters. I can see no discernible difference between returning YES or NO. Apple's docs aren't any help--obviously you return YES or NO to signal whether you successfully handled the open file event or not, but what are the actual consequences of these two outcomes?

I'm also not familiar enough with the framework to glean any knowledge from stepping through the call stack with the debugger.

To test my app I'm running it from Xcode (not handling cold start yet) then running it $ open -a MyApp somefile.txt commands in terminal as well as doing a File > Open With in Finder and choosing my app.

Related question, but about a different problem (unanswered): Very slow to open a file with application:openFile: after returning

4

0 回答 0