Re: Subclassing NSWindowController
Re: Subclassing NSWindowController
- Subject: Re: Subclassing NSWindowController
- From: Bill Cheeseman <email@hidden>
- Date: Thu, 05 Dec 2002 18:14:27 -0500
on 02-12-05 12:51 PM, Mike Ferris at email@hidden wrote:
>
What you want to do, though, especially when using separate NSDocument
>
and NSWindowController objects, is be sure to keep model and view
>
separated. In the case of text, this boils down to the content vs. the
>
NSTextView. The document should own the content, the controller should
>
own the view. The easiest way is to make the NSDocument own an
>
NSTextStorage which is the "model" for the text content. Part of
>
hooking your NSWindowController up to its document (in an override of
>
-setDocument: perhaps) should be adding the -layoutManager of the
>
controller's NSTextView to the text storage owned by the document.
>
>
Here's one possible implementation strategy:
You'll find sample code for doing what Mike suggests in my Vermont Recipes
book. It's cleverly hidden away in Recipes 16 and 17, which are supposedly
about drawers and multiple windows but are really mostly about keeping the
model and the controller separate when using the Cocoa text system in a
document-based application.
--
Bill Cheeseman - email@hidden
Quechee Software, Quechee, Vermont, USA
http://www.quecheesoftware.com
The AppleScript Sourcebook -
http://www.AppleScriptSourcebook.com
Vermont Recipes -
http://www.stepwise.com/Articles/VermontRecipes
Croquet Club of Vermont -
http://members.valley.net/croquetvermont
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.