core data + undo + accessors

  • 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

    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?

    John Clayton
    Skype: johncclayton
previous month december 2008 next month
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31        
Go to today