Re: core data, undo and redo
Re: core data, undo and redo
- Subject: Re: core data, undo and redo
- From: Martin Hewitson <email@hidden>
- Date: Sat, 22 May 2010 18:54:24 +0200
Thanks, Jerry. I was trying to let core data do its thing, but I was getting errors associated with the regular instance variables of the managed objects after an undo, so I started down this road of trying to somehow handle myself the releasing and re-instantiating of the instance variables. Probably I took the wrong track and I should rather try harder to figure out where the problem was, and fix that, rather than try to get around it.
Thanks for the advice,
Martin
On May 22, 2010, at 6:50 PM, Jerry Krinock wrote:
>
> On 2010 May 22, at 09:36, Martin Hewitson wrote:
>
>> In particular I have an NSManagedObject subclass which has properties which are not part of the core data model, but are instead (in some sense) transient.
>
> I believe you're referring to what I'd call these "regular instance variables".
>
>> For example, one property is an NSTextStorage which I create in awakeFromFetch:. At the moment, I have to release the NSTextStorage just before I remove the item from the tree-controller. I rather expected (perhaps wrongly) that removing the item from the tree-controller (which is bound to the managed object context) would result in the particular NSManagedObject being released, but I don't see that happening.
>
> That's true. Core Data will release objects when it gets good and ready, and there's no telling when that is.
>
>> I also checked to see if didTurnIntoFault: is called on the item, but it isn't.
>
> It will be called eventually. My understanding is that any clean-up code which you'd usually put in -dealloc for a regular object should be put in -didTurnIntoFault for a managed object. Seems to work for me.
>
>> My main problem is that, when I undo the removing of items from the tree, I need to reinstate the transient properties like the text storage.
>
> But if you didn't release them in the first place, you wouldn't need to put them back in the second place.
>
>> When I undo, awakeFromFetch: isn't called, neither is awakeFromInsert:. So where does one get the chance to 'handle things' after an undo? I saw in the documentation the method awakeFromSnapshotEvents: but there it says "Available in iPhone OS 3.0 and later". What about if I'm developing for 10.5?
>
> I think you should sit back and let Core Data do its work.
>
> _______________________________________________
>
> 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
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Martin Hewitson
Albert-Einstein-Institut
Max-Planck-Institut fuer
Gravitationsphysik und Universitaet Hannover
Callinstr. 38, 30167 Hannover, Germany
Tel: +49-511-762-17121, Fax: +49-511-762-5861
E-Mail: email@hidden
WWW: http://www.aei.mpg.de/~hewitson
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
_______________________________________________
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