Re: Is this a bug in AppDelegate?
Bill Pitcher
Sorry, I'll try and be more Objective.
toggle quoted message
Show quoted text
Working back in Aqua 10.0 there was no documentation, LOL and we had to read the message names and headers to get an understanding of this NextStep puzzle. With these very very old Objects, you'll need to base your assumption on trying to understand the mindset of the API more than the documentation. The key word is Should, a method with Should in it's name is to allow/stop something from happening. Application Should Open Untiled File, return YES and the Application Should open an untiled File, NO and it Should not. It's the switch "Invoked immediately before opening an untitled file." to determine if the untitled file should be created at all. This comes before the... At this point there are 2 ways the Application can Open an Untitled File, the first is without Delegate intervention. The Application can instigate an NSDocument and wire up the Controllers and Window automagicly, OR the Delegate gets to do it, by implementing the applicationOpenUntitledFile message which is "Sent directly by theApplication to the delegate to request that a new, untitled file be opened.". This is the Delegate's opportunity to do all the heavy lifting and make any changes to the default behaviour. This Delegate message needs to report back to the Application "YES if the file was successfully opened or NO if it was not." if YES, all is good, end of story. If NO, and this I think is where you are surprised, Because you have told the Application YES we must have an Untiled File, but the Delegate has reported NO I haven't been successful making one, the Application knows it needs to make an Untiled File, so it continues on to make it's default Untiled File. In the Flow applicationShouldOpenUntitledFile returning NO stops the flow, else we detour to the Delegate to see if it can create Untiled in applicationOpenUntitledFile, was the Delegate successful YES stops the Flow, NO back to the App which now makes the Untitled File. https://developer.apple.com/library/archive/documentation/DataManagement/Conceptual/DocBasedAppProgrammingGuideForOSX/AdvancedTopics/AdvancedTopics.html#//apple_ref/doc/uid/TP40011179-CH7-SW6 Down the page, Message Flow in the Document Architecture, does NOT show the Application process but it illustrates this Flow idea for Documents, a chart like this for App startup would be nice. "This message flow provides many opportunities for you to customize the behavior of your app by overriding methods" I'm sorry if this seem a bit pedantic but trust me the Objects that came with Next have a distinct flavor/idiom and the best way to understand them is read the documentation in this idiom. If you don't get the expected results, do exactly what you have done, make a TestApp, try the options then re-read the documentation with this new understanding, and trying to understand the idiom, After 20yrs the documentation is "Generally" correct. I think Apple will not be changing how 10.0 Objects function, at best a bug report might get a change in documentation, but on something this old and the upcoming move to UIKit I wouldn't think so. Hope this helps with your journey back into the past;-) old documentation links below. cheers Bill https://developer.apple.com/library/archive/documentation/General/Conceptual/DevPedia-CocoaCore/Introduction.html#//apple_ref/doc/uid/TP40008195-CH68-DontLinkElementID_2 https://developer.apple.com/library/archive/documentation/General/Conceptual/DevPedia-CocoaCore/Delegation.html#//apple_ref/doc/uid/TP40008195-CH14 https://www.cocoawithlove.com/2009/06/method-names-in-objective-c.html Bill Pitcher Tutor Literacy Aotearoa - Dunedin On 8/08/2018, at 8:07 AM, Peter Teeson via Groups.Io <peter.teeson@...> wrote: |
|