Is this a bug in AppDelegate?


Peter Teeson
 

macOS Yosemite 10.10.5; Xcode 6.4
In testing a vanilla Document app I tracked down what may be a bug in Cocoa.

I expected that the app would not open an untitled file because
applicationOpenUntitledFile returned NO. 
But an untitled file was in fact opened in a window.

OTOH if I change applicationShouldOpenUntitledFile return to NO then 
no file is opened and the app launches without a window, just a menu bar.

So is it a bug or is my expectation incorrect? 

- (BOOL)applicationShouldOpenUntitledFile:(NSApplication *)sender {
    // Use this method to decide whether the application should open a new, untitled file.
    // Note that applicationOpenUntitledFile: is invoked if this method returns YES.

    

    return YES; // YES if the application should open a new untitled file or NO if it should not.
}

- (BOOL)applicationOpenUntitledFile:(NSApplication *)theApplication {
    // Sent directly by theApplication to the delegate to request that a new, untitled file be opened.

    

    return NO; // YES if the file was successfully opened or NO if it was not.
}

Join cocoa@apple-dev.groups.io to automatically receive all group messages.