> On Jan 4, 2017, at 7:16 PM, Quincey Morris 
> <quinceymor...@rivergatesoftware.com> wrote:
> 
> On Jan 4, 2017, at 14:11 , Jean-Daniel <mail...@xenonium.com> wrote:
>> 
>> When using storyboard, the only way to instantiate window is by getting a 
>> reference to the window controller (by using 
>> -instantiateControllerWithIdentifier:), so it should not be an issue.
> 
> The problem I was referring to is when the window [scene] is in the initial 
> controller. There’s no way (AFAIK) that you can statically set up a reference 
> to the WC in any combination of IB/code, and of course the storyboard 
> instantiation is not in your code.
> 
> Again AFAIK, you can get a reference to this WC from the window, and you can 
> get the [main] window from the NSApplication object, or from a view 
> controller’s view, but all of these things require you to defer getting the 
> reference until the objects are created and functional.
> 
> Or, you can subclass NSWindowController, and have the windowDidLoad override 
> add a controller reference to data structures somewhere.
> 
> But I think the old days when the template project provided a window 
> controller property on the app delegate for you are gone.
> 
> Of course, I’d be extremely happy to be wrong about this. (I assume the tea 
> leaves indicate that window controllers are on the way out, so don’t get too 
> used to them.)

Why would they go away, since they’re part of the document system (with 
NSDocument and NSDocumentController). The first thing I do with the default 
document-based project is to factor out the window (controller) code and 
storyboard out of the Document class and Main storyboard to separate files. 
Easier to handle early in case I add more code.

One big question I had was how to remove the window (controller) reference. I 
think there’s an NSNotification whenever a window closes; do I have to use that 
(or the equivalent window delegate method) to flag when to remove the pointer 
from my collection object (or set the single reference to NIL)?

— 
Daryle Walker
Mac, Internet, and Video Game Junkie
darylew AT mac DOT com 


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to