• 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: Safe cross references between scenes in an OS X storyboard
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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 08:59:38 -0500

> On Mar 9, 2016, at 8:42 AM, Roland King <email@hidden <mailto:email@hidden>> 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 remembered this is a more direct way to do it:

lazy var mainContentViewController: MainContentViewController? = {
	NSApp.mainWindow?.contentViewController as? MainContentViewController
}()

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 now, I guess it is a sensible approach. It has less to do with storyboards than with the longstanding fact that NSApplication has a 'mainwindow' property and NSWindow has a 'contentViewController' property.

--

Bill Cheeseman - email@hidden <mailto: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


  • Follow-Ups:
    • Re: Safe cross references between scenes in an OS X storyboard
      • From: Quincey Morris <email@hidden>
References: 
 >Safe cross references between scenes in an OS X storyboard (From: Bill Cheeseman <email@hidden>)
 >Re: Safe cross references between scenes in an OS X storyboard (From: Roland King <email@hidden>)

  • Prev by Date: Re: UICollectionView Moving
  • Next by Date: Re: Safe cross references between scenes in an OS X storyboard
  • Previous by thread: Re: Safe cross references between scenes in an OS X storyboard
  • Next by thread: Re: Safe cross references between scenes in an OS X storyboard
  • Index(es):
    • Date
    • Thread