CoreData, setValue, needsDisplay, and undo
CoreData, setValue, needsDisplay, and undo
- Subject: CoreData, setValue, needsDisplay, and undo
- From: Timothy Larkin <email@hidden>
- Date: Fri, 16 Mar 2007 18:19:44 -0400
In a common situation, a change in the value of an object attribute
requires an update of some rectangle in a view. Without CoreData, I
would create some code to invalidate the rectangle in the set<key>
method. Then I can use prepareWithInvocationTarget to specify that
the undo manager calls set<key> when it performs an undo, and the
proper invalidation happens easily.
However, when the undo manager of a managed object context does an
undo, it doesn't call set<key>, as far as I can tell, but calls
setPrimitiveValue. Since we are not supposed to override this method,
I can't use it to invalidate the rect. I could still call
prepareWithInvocationTarget in the set<key> method, but this is
redundant, and in fact, by the time set<key> is called via the
invocation, the key's change has already been undone, so I don't have
access to the old value, which I need to complete the invalidation.
I could register as an observer for all the attributes, which may be
the canonical solution, but if there are large numbers of such items
in the view, then keeping track of all the observations gets messy.
The solution used by the TilePuzzle example is to register to receive
undo notifications, and when a notification is received, to
invalidate the entire view. This works well, but seems like overkill.
Is there some other solution that I'm not seeing? What is the best
practice?
--
Timothy Larkin
Abstract Tools
Caroline, NY
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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