Best Advice?
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