Re: NSDocument open/new file problem when model object instance is in nib.
Re: NSDocument open/new file problem when model object instance is in nib.
- Subject: Re: NSDocument open/new file problem when model object instance is in nib.
- From: Matt Neuburg <email@hidden>
- Date: Wed, 16 Aug 2006 10:11:55 -0700
- Thread-topic: NSDocument open/new file problem when model object instance is in nib.
On Tue, 15 Aug 2006 14:22:47 -0700 (PDT), joe OneNinetyTwo
<email@hidden> said:
>I have an instance of my model object inside
>MyDocument.nib.
>
>This instance is the content for an
>NSObjectController, which, in turn, is bound to two
>NSArrayControllers, which are bound to two
>NSTableViews of two NSArrays inside my model object.
>
>The corresponding model object inside MyDocument.m via
>IBOutlet is connected to the model object instance
>inside the nib.
>
> When I create a New document, the window controller
>opens the nib, unarchives the model instance, and sets
>it as the model object inside MyDocument object.
>
>Now, here's my problem. If I open a file, then
>loadDataRepresentation unarchives the coded model
>object saved in the file, and then the window
>controller opens the nib, unarchives the model
>instance in the nib, and sets it as the model object
>inside MyDocument object. The model object that was
>in my file gets released and deallocated, and I'm
>looking at a new document window.
>
>If I remove the model object instance from the nib,
>then I lose the content for the ObjectController.
>
>Any suggestions on how I can solve this problem?
When you open a file, and loadDataRepresentation unarchives the coded model
object, retain it off in an ivar. Then in windowControllerDidLoadNib, fix
the problem. This is SOP. m.
--
matt neuburg, phd = email@hidden, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
<http://www.amazon.com/gp/product/0596102119>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden