Aloha,

I have a document which contains a model object created in the document's -init method, and I have a ton of bindings hooked up to this model by binding to the document nib's File's Owner and then using the key path "myModel.whateverProperty". This works spectacularly.

To save the document, I simply archive this model object, and save the resulting data. For reading document data, I simply unarchive the data and I get back an instance of the model object. This works spectacularly.

The tricky part is that I can't replace the existing model object that was created in the document's -init method because all of the bindings are hooked up to it. I thought I could simply get away with doing the steps below, but I still get an error at runtime because the bindings are still bound to the object that was released in the autorelease pool.

        [self willChangeValueForKey:@"myModel"];
        [myModel autorelease];
        myModel = theUnarchivedModel;
        [self didChangeValueForKey:@"myModel"];

So what should I do? After I unarchive the object I can certainly assign every property from theUnarchivedModel instance to the existing myModel instance, but that's tedious. Is there a correct and simple way of doing this? The only options I see are assigning properties one by one (ick), tearing down the bindings (major ick), or having some kind of proxy object which entails having a whole bunch of glue code (major ick).


Thanks,

--
Seth Willits




_______________________________________________

Cocoa-dev mailing list ([email protected])

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to