• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
CoreData, setValue, needsDisplay, and undo
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: CoreData, setValue, needsDisplay, and undo
      • From: Chris Hanson <email@hidden>
  • Prev by Date: Re: Embeding a view into another application
  • Next by Date: Re: Problem redrawing views while window resize button is held
  • Previous by thread: Re: Move the Apple Menu
  • Next by thread: Re: CoreData, setValue, needsDisplay, and undo
  • Index(es):
    • Date
    • Thread