• 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
Re: Observing Undo in a Core Data App
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Observing Undo in a Core Data App


  • Subject: Re: Observing Undo in a Core Data App
  • From: Joshua Scott Emmons <email@hidden>
  • Date: Fri, 24 Feb 2006 11:19:53 -0600

What do I observe to see if an item has been placed back into the NSManagedObject context via Undo. Undo works: the most recently deleted object is put back into the context - it's there when I restart the application and reload the array. I just need to know when an object is put back into the context so that I can update my UI on the fly. Any suggestions on how to do this?

My solution to this was to crate a base managed object, "Office". Office has a to-many relationship called "employees". My array controller adds and deletes Employee managed objects from this to- many relationship. Then, to recognize undo/redos, I just KVO Office's "employees" relationship.


This was a quick fix when I did it. I didn't look for a better way, and there very well might be one. But this worked well enough for me.

Oh, one more note. When proceessing the KVO with - observeValueForKeyPath:ofObject:change:context:, NSKeyValueChangeKindKey is NSKeyValueChangeRemoval on deletions and NSKeyValueChangeInsertion on insertions. But as I recall it's NEITHER on undos and redos. Just a heads up.


Cheers,
-Joshua Emmons _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden
References: 
 >Observing Undo in a Core Data App (From: Michael Clark <email@hidden>)

  • Prev by Date: Re: double-binding?
  • Next by Date: String causes NSLog to crash
  • Previous by thread: Observing Undo in a Core Data App
  • Next by thread: Re: Observing Undo in a Core Data App
  • Index(es):
    • Date
    • Thread