Hi. 

My OS-X app is using ARC, is CoreData Document-Based (using the old 
NSPersistentDocument) and uses 10.9 SDK. 

Up until now, I did nothing on my behalf to support user Undo/Redo, still the 
application seemed to work fine. I was very impressed with Cocoa (this 
millionth time).

However. In some of my application controller  objects, I maintain and rely on 
references to CoreData entities (NSManagedObject instances) for the application 
state (The current entity I'm working on, etc.) 

When user selects "Undo" (or cmd-Z) - my controllers lose track of the 
application state. Last created entities get deleted by Core-Data, and my 
references point to dead entities. In short - I lose synchronization with my 
model.

If I set those entity references to "strong" then the NSManagedObjects can't be 
released of course, but I'll soon crash because they were deleted from 
CoreData. If I make them weak references insted, they will nullify upon undo 
--- but no one will ever set these references to their previous values (the 
older state). 

It seems I need to add my own "undo actions" to the automatic mechanism, but I 
don't know WHEN is the right time to do it, WHAT undo-managed I should address, 
and HOW to group my "undo" and "redo" actions, with the CoreData's undo actions.

I tried to dive into the Undo architecture documentation, but got confused very 
soon, especially because CoreData does its thing independently of other parts 
of my program.

Any hint or sample-code reference, or clarifying note will be greatly 
appreciated!

Motti Shneor.

---
But they are useless ---
         they can only provide answers! 

(Pablo Picasso 1881-1973 about Computers).





_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please 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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to