Skip navigation.
 
mlRe: NSDocument open/new file problem when model object instance is in nib.
FROM : Matt Neuburg
DATE : Wed Aug 16 19:11:55 2006

On Tue, 15 Aug 2006 14:22:47 -0700 (PDT), joe OneNinetyTwo
<<email_removed>> 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_removed>, <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>

Related mailsAuthorDate
mlRe: NSDocument open/new file problem when model object instance is in nib. Matt Neuburg Aug 16, 19:11
mlRe: NSDocument open/new file problem when model object instance is in nib. joe OneNinetyTwo Aug 17, 02:42