• 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
Best Advice?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Best Advice?


  • Subject: Best Advice?
  • From: Michael de Haan  <email@hidden>
  • Date: Sun, 18 Oct 2015 05:05:00 -0700

I am using a separate, second “standAlone" Window to display a SplitViewController. Design is StoryBoard, for an OS X application.
From appDelegate, I instantiate the SplitViewController in “applicationDidFinishLaunching"


let storyBoard = NSStoryboard(name: "Main", bundle: nil)
resultWindowController = storyBoard.instantiateControllerWithIdentifier("ResultController") as! NSWindowController
resultWindowController.showWindow(self)

In this particular “testBed” configuration, I initialized a Core Data Stack in AppDelegate. My goal is to initialize the splitViewItem’s  context once AppDelegate has setup the stack.

In the end, I resorted to posting a notification in “applicationDidFinishLaunching"

 "NSNotificationCenter.defaultCenter().postNotificationName("SetUpComplete", object: self.managedObjectContext)”

for the interested parties, but this seems to duplicate a lot of code in each of the children’s view controllers.

viz

 NSNotificationCenter.defaultCenter().addObserverForName("SetUpComplete", object: nil, queue: NSOperationQueue.mainQueue()) { (notification) -> Void in

            self.managedObjectContext = notification.object as! NSManagedObjectContext
   }

where  “managedObjectContext” is simply a var in the Child View Controller

Is there a simpler way of doing this? Maybe initializing the actual splitViewController and using this as a source of the context for it’s children?

Thank you.


_______________________________________________

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: Best Advice for accessing App Delegate's Managed Object Context
      • From: Jerry Krinock <email@hidden>
  • Prev by Date: Re: -[NSThread start] blocks ?!?
  • Next by Date: Setting the contentOffset of a UICollectionView during update
  • Previous by thread: Re: -[NSThread start] blocks ?!?
  • Next by thread: Re: Best Advice for accessing App Delegate's Managed Object Context
  • Index(es):
    • Date
    • Thread