Re: Safe cross references between scenes in an OS X storyboard

2016-03-10 Thread Bill Cheeseman
> On Mar 9, 2016, at 7:22 PM, Quincey Morris > wrote: > > No, it’s *really* a property, so like this: > >> class MainContentViewController: NSWindowController { >> >> static private(set) var controller: MainContentViewController! // >> defaults to nil until set >> >> override

Re: Safe cross references between scenes in an OS X storyboard

2016-03-09 Thread Quincey Morris
On Mar 9, 2016, at 16:22 , Quincey Morris wrote: > >> NSWindowController Sorry, my brain was stuck on window controllers, but you’re doing this in the view controller. Same code, really. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Pleas

Re: Safe cross references between scenes in an OS X storyboard

2016-03-09 Thread Quincey Morris
On Mar 9, 2016, at 13:31 , Bill Cheeseman wrote: > >static var controller: MainContentViewController? { >get { >return MainContentViewController.controller >} >set(newController) { >MainContentViewController.controller = newController >

Re: Safe cross references between scenes in an OS X storyboard

2016-03-09 Thread Bill Cheeseman
> On Mar 9, 2016, at 1:00 PM, Quincey Morris > 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 yo

Re: Safe cross references between scenes in an OS X storyboard

2016-03-09 Thread Quincey Morris
On Mar 9, 2016, at 11:36 , Bill Cheeseman wrote: > > But don't I still need to use optionals if I declare the window controller or > content view controller instance variable in AppDelegate but don't set it > until later in the window controller's windowDidLoad() method? I am still at > risk o

Re: Safe cross references between scenes in an OS X storyboard

2016-03-09 Thread Bill Cheeseman
> On Mar 9, 2016, at 1:00 PM, Quincey Morris > wrote: > > On Mar 9, 2016, at 05:59 , Bill Cheeseman wrote: >> >> But the main thrust of my question was whether this is a safe and sensible >> way to crossreference other storyboard scenes -- at least when >> prepareForSegue(_:sender:) isn't a

Re: Safe cross references between scenes in an OS X storyboard

2016-03-09 Thread Quincey Morris
On Mar 9, 2016, at 05:59 , Bill Cheeseman wrote: > > But the main thrust of my question was whether this is a safe and sensible > way to crossreference other storyboard scenes -- at least when > prepareForSegue(_:sender:) isn't available, as it isn't here. Having thought > about it for a while

Re: Safe cross references between scenes in an OS X storyboard

2016-03-09 Thread Bill Cheeseman
> On Mar 9, 2016, at 8:42 AM, Roland King > wrote: > > just > > return NSApp.mainWIndow?.contentViewController as? > MainContentViewController > > works without all the guard and intermediate variables and still returns the > same optional. Thanks. I should have

Re: Safe cross references between scenes in an OS X storyboard

2016-03-09 Thread Roland King
> On 9 Mar 2016, at 21:32, Bill Cheeseman wrote: > > I am using storyboards in an OS X application written in Swift 2. It is a > single window "shoebox" application that does not use NSDocument or Core > Data. It is built with the Xcode 7.2.1 storyboard template, where the > storyboard entry

Safe cross references between scenes in an OS X storyboard

2016-03-09 Thread Bill Cheeseman
I am using storyboards in an OS X application written in Swift 2. It is a single window "shoebox" application that does not use NSDocument or Core Data. It is built with the Xcode 7.2.1 storyboard template, where the storyboard entry point is the main window controller scene and a "window conten