core data + undo + accessors
core data + undo + accessors
- Subject: core data + undo + accessors
- From: John Clayton <email@hidden>
- Date: Sun, 07 Dec 2008 14:07:48 +0100
Hi all,
Tell me if I'm missing the point please.
With core data and undo, apparently the undo system + core data (not
sure if its a combination of them both), do NOT fire accessor methods
on core-data objects when the undo manager changes the state of the
object model.
For example (outlined in a previous email), I have a 'Layer' object
with many 'Effects'. There is a to-many relationship from the layer
to the effects instance called, surprise surprise, 'effects'.
If I create an Effect instance - the accessor methods are fired. If I
then hit Ctrl-Z to undo that, none of the accessor methods are fired,
only KVO notifications are sent.
Doesn't this behaviour entirely invalidate the idea of putting
business/program logic into your core-data derived class accessor
methods?
I had thought that it was sensible to derive classes from my core-data
objects, and then put logic in them - e.g. when an object is added
into a relationship, I can then begin listening for changes on my
parent for example - but the fact that none of my accessors are called
when the undo manager begins modifying my object graph means that it
is *impossible* to rely on using custom accessors because they are not
always called when the model is changed.
This in turn leads me to believe that I should only use core-data for
pure data storage, and nothing else. And that I should never put any
model-changing logic into any custom accessors on my NSManagedObject
accessors. Further, the only reason I can see to have custom accessors
would be to provide type safety and an easier programming interface to
the core-data based API that I am writing.
Have a missed the point? Are there other posts / articles you think
could help me?
Thanks
--
John Clayton
Skype: johncclayton
_______________________________________________
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