• 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: Undo and NSArrayController and CoreData
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Undo and NSArrayController and CoreData


  • Subject: Re: Undo and NSArrayController and CoreData
  • From: Jason Swain <email@hidden>
  • Date: Thu, 9 Mar 2006 21:08:19 +0000

I've found a workaround for this, but it is not very nice. I monitor the ManagedObjectContext for changes, and when I detect a change to one of the objects I am interested in I call -rearrangeObjects on the NSArrayController. This does work, but it's not the way things should be.

To answer your question, I create the object by calling the -add method on the array controller. This works correctly and updates the TableView. The change that does not work correctly is when undo is used (on the NSManagedObjectContext's undoManager). So the updates happen behind the scenes as part of the core data undo support. In this case the array controller still thinks it has the deleted object, but the managed object context is updated correctly.


Jason

On 9 Mar 2006, at 19:32, Miguel Sanchez wrote:

can you tell us a little more about how it is that you're updating your model? Are you using a proper accessor method (with the will/ did calls)? are you removing things from the detail relationship that is represented in the array controller?

your first focus should be not in trying to force the array controller to update, but in seeing if you are changing your model through the official channels so that Key Value Observing can initiatethe correct updates.



- Miguel


On Mar 9, 2006, at 12:49 AM, Jason Swain wrote:

I have a NSArrayController that is bound to the selection of another NSArrayController (don't think this is significant, but just in case). All works fine for user interaction, but when Undo is used, i.e. the Managed Object Model is changed underneath the NSArrayController it does not update correctly.

I have some debug code that gives me a count of the objects in the array, both through the NSArrayController and directly from the CoreData objects. The direct count is correct, and NSArrayController still has the old array of objects (before the undo). So how do I get the NSArrayController to update? I thought that this would happen automatically through the binding, but it does not. I've tried using any methods that looked remotely like they would cause the array controller to reread it's data (-fetch etc), but this does not help.


Jason _______________________________________________ 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


Jason Swain email@hidden mobile +44 7917 524 192

_______________________________________________
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: 
 >Undo and NSArrayController and CoreData (From: Jason Swain <email@hidden>)
 >Re: Undo and NSArrayController and CoreData (From: Miguel Sanchez <email@hidden>)

  • Prev by Date: Getting true parent window of views in drawers
  • Next by Date: iTMS movie downloads in QTMovieView
  • Previous by thread: Re: Undo and NSArrayController and CoreData
  • Next by thread: How to construct CIImage from NSImage? Please help.
  • Index(es):
    • Date
    • Thread