What happens when an application: openFile returns NO instead of YES in my NSApplicationDelegate?

I am learning Objective-C / Cocoa and starting to read when handling open document events. It seems like the standard way is only to implement application:openFile or application:openFiles in your NSApplicationDelegate.

So here is 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 application, if that matters. I do not see the distinguishable difference between returning YES or NO . Apple docs do not help - obviously, you will return YES or NO to indicate whether you have successfully processed the open file event or not, but what are the actual consequences of these two results?

I am also not familiar with the framework enough to get information about the transition through the call stack using the debugger.

To test my application, I launch it from Xcode (until I process a cold start), then run its $ open -a MyApp somefile.txt command in the terminal, and also execute the File> Open With in Finder command and select my application.

A related question, but about another problem (unanswered): Very slowly open the file with the application: openFile: after returning

+4
source share

Source: https://habr.com/ru/post/1432136/


All Articles