NSDocument and NSViewControllers
NSDocument and NSViewControllers
- Subject: NSDocument and NSViewControllers
- From: Rick Mann <email@hidden>
- Date: Fri, 04 Dec 2015 16:32:05 -0800
I have a very complex "document" that I'm writing an editor for. It's a collection files, lending itself to the bundle document style. I use NSFileWrappers, and when I open one of these in my app, I get called to read the contents. I don't have to read every file all the time, it depends on what aspect the user is editing.
One part of the document is a 3D mesh file. I'm using SceneKit to display it, and 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".
But NSViewController has a "representedObject". This suggests something outside the VC can inject the model into the VC, improving decoupling between the VC and the NSDocument subclass. But I don't see any good way to get at the VC, except in makeWindowControllers(). Is that the right place?
Part of the issue is that I may have multiple windows possible for each document (like I said, it's quite complex). Certainly multiple views, and I'm not a big fan of Xcode-style all-in-one-window UIs. It might work better in this particular case, since it's much more rare the user needs multiple aspects open simultaneously (like, multiple source files). In any case, a particular window may never be opened, so I don't want to make all the window controllers at once.
What do most people do in this situation?
TIA,
--
Rick Mann
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