Re: Enabling undo in a CoreData app?
Re: Enabling undo in a CoreData app?
- Subject: Re: Enabling undo in a CoreData app?
- From: Jim Correia <email@hidden>
- Date: Sat, 29 Apr 2006 19:54:57 -0400
On Apr 29, 2006, at 7:13 PM, email@hidden wrote:
Well, it's an app that interracts with Flickr, so updating the
local store only has meaning if I also pass those changes back to
Flickr. And that's support that I'm adding right now. So, I really
do need to prevent undo of database changes - as I fetch data from
Flickr periodically or based on user actions and then do all my
inserts, I don't want the user to undo that.
The list of events where the user actually makes a meaningful
change and should be able to undo it is currently very small
compared to all the changes and machinations that the app goes
through without the user.
One thing you may wish to consider, rather than trying to wrangle the
undo manager, is to use separate managed object contexts. The user
does all the work in one context, and all the automated Flickr stuff
happens in another. You can listen for the MOC saved notification to
synchronize the MOCs. (Or it may just be appropriate to reset the
Flickr MOC after doing work, then saving the changes.)
Also, you probably don't want to be manually registering undo
actions for CoreData operations. CoreData already manages undo, so
let it. Normally it will process the pending changes at the end of
the current iteration of the event loop. If you have special
needs, you can trigger this manually by sending -
processPendingChanges to the MOC.
This is similar to what I mentioned above - the database action on
my side has no meaning without associated web service calls. Those
calls are not currently 100% built into my model (and I don't think
I want them to be), so a controller object coordinates this. When
an "add" happens, the controller enables undo, makes the changes in
the coredata store, and generates the appropriate web services.
Then it disables undo again.
Just beware that unless you send -processPendingChanges yourself,
CoreData is going to do that at the end of the current event loop.
This is when CoreData will post changes to the undo manager, and that
is outside of your disable/enableUndoRegistration calls.
Additionally, if I take out ALL the disableUndoRegistration calls,
I still don't get an enabled Undo menu item - no matter how much I
change my store. And I can ask the undo manager whether undo
registration is enabled, and it replies with YES.
This sounds like a responder chain problem, unrelated to the rest of
your undo manager wrangling.
JIm
_______________________________________________
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