• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSDocument and NSViewControllers
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: NSDocument and NSViewControllers
      • From: Rick Mann <email@hidden>
References: 
 >NSDocument and NSViewControllers (From: Rick Mann <email@hidden>)

  • Prev by Date: Re: Swift screensavers in Ubuntu?
  • Next by Date: Re: ARC and IBOutlet - strong vs weak......
  • Previous by thread: NSDocument and NSViewControllers
  • Next by thread: Re: NSDocument and NSViewControllers
  • Index(es):
    • Date
    • Thread