Re: core data, undo and redo
Re: core data, undo and redo
- Subject: Re: core data, undo and redo
- From: Jerry Krinock <email@hidden>
- Date: Sat, 22 May 2010 09:50:08 -0700
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