Re: NSDocument and NSViewControllers
Re: NSDocument and NSViewControllers
- Subject: Re: NSDocument and NSViewControllers
- From: Jerry Krinock <email@hidden>
- Date: Sat, 05 Dec 2015 05:24:13 -0800
> On 2015 Dec 04, at 16:32, Rick Mann <email@hidden> wrote:
>
> I have an NSViewController subclass and SCNView subclass. I can get at the document from the NSViewController subclass via a rather cumbersome "let doc = self.view.window?.windowController?.document as? ModelDocument”
I just happened to have done that yesterday afternoon. It seemed like the most logical approach to me. “Going to the source”, even via a circuitous key path, is usually more robust than adding properties for convenience.
Just make sure you can guarantee that the window and view have been loaded previously in your situation, or you’ll get nil. I’ve also used that as a key path in Cocoa Bindings. In that case, it’s usually OK to return nil initially.
_______________________________________________
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