Re: Safe cross references between scenes in an OS X storyboard
Re: Safe cross references between scenes in an OS X storyboard
- Subject: Re: Safe cross references between scenes in an OS X storyboard
- From: Bill Cheeseman <email@hidden>
- Date: Wed, 09 Mar 2016 16:31:16 -0500
> On Mar 9, 2016, at 1:00 PM, Quincey Morris <email@hidden> wrote:
>
> What you can do instead is subclass NSWindowController, and use ‘windowDidLoad’ as your opportunity to save your own strong reference to the WC. (In Swift, I think I’d make it a static property of the WC class. This also lets you check that nothing creates a second main window.)
I haven't been able to figure out how to do this, and I've run out of time for today. Any hints would sure be appreciated.
I'm doing it in my MainContentViewController class. I have declared the static variable mainContentViewController, with getter and setter. I have set its value when the view loads, in viewDidLoad(). And I use the static variable in AppDelegate. It compiles without error, but at runtime the setter is called repeatedly until it crashes -- apparently an infinite loop.
Like so:
static var controller: MainContentViewController? {
get {
return MainContentViewController.controller
}
set(newController) {
MainContentViewController.controller = newController
}
}
--
Bill Cheeseman - email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden