Abandoning NSDocument for an app
Abandoning NSDocument for an app
- Subject: Abandoning NSDocument for an app
- From: Daryle Walker <email@hidden>
- Date: Thu, 14 Aug 2014 03:42:32 -0400
I’ve been trying to follow Apple’s guide on WebView, and some parts use the NSDocument architecture for their browser app part examples. However, the dependencies for a document app is: model (custom) -> model management in the large (NSDocumentController) -> individual models (NSDocument) -> display & manipulation of models (NSWindowController, NSWindow, and NSView subclasses). Since a WebView both holds the browser stuff and is a control, the dependency relationship between it and NSDocument is the wrong way. That really hurts in operations that NSDocument is supposed to provide without its windows (i.e., on-app-open file load or print). Worse, all the file handling stuff and type management that NSDocument (and NSDocumentController) have not only seem superfluous, they get in the way sometimes. (File loads and saves are more like imports and exports for a browser app.)
Since a WebView has to associated with a NSWindow to be useful here, I’m thinking of abandoning NSDocument from my app and using the bunch-of-windows app model used for non-NSDocument apps. I want to convert my existing files over, with some changes, so my git system doesn’t go nuts with a complete-throw-away-and-start-over. I really don’t want to redo my NSWindow from scratch. I could rename the window’s nib, rename the document class and rebase it off NSWindowController, and keep the app delegate as-is to start. The questions I got are:
1. If I rebase the document class from NSDocument to NSWindowController, the NSDocumentController stuff won’t be created at all, right? However, is there anything from NSDocumentController I should keep?
2. How do I redo the app delegate to create windows (with the new command).
3. Are there differences between the menu bar for a new document-less project and a NSDocument-based one that I have to fix since I’m switching?
—
Daryle Walker
Mac, Internet, and Video Game Junkie
darylew AT mac DOT com
_______________________________________________
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