mirror of
https://github.com/JohnEstropia/CoreStore.git
synced 2026-01-11 20:00:30 +01:00
Undoing changes #17
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @yoiang on GitHub (Nov 4, 2015).
Hey @JohnEstropia !
I've just started using CoreStore and I'm excited!
I was wondering, are there were any plans to expose some sort of undo functionality similar to or using the NSUndoManager? Or can something similar be achieved already with Unsafe Transactions?
Thanks!
@JohnEstropia commented on GitHub (Nov 5, 2015):
@yoiang Thanks for the feedback!
If I remember correctly, the
undoManagerfor all transactions should be intact, but direct access to theNSManagedObjectContextis currently not allowed on async and sync transactions. You are right that you can invoke undo operations on theUnsafeDataTransactionthough!Can you share your use-case for needing undo operations? If I find enough demand for it I might enable it on all transaction classes as well.
@yoiang commented on GitHub (Nov 13, 2015):
Hey @JohnEstropia ! Sorry for the late response.
A use case I run into a fair bit is a View that visualizes a Model of some kind and let's say we provide a View and an Edit mode, during the life of the View the user may edit changes to the Model, press Cancel and undo all changes or undo particular changes, or press Done and have the changes committed.
Lemme know if I could be more specific or provide any more info.
@JohnEstropia commented on GitHub (Nov 14, 2015):
@yoiang
Okay, I think
UnsafeDataTransactions fits well for such cases. You should be able to implement this right now, but I'll add some utility methods to the transactions so we can save some typing :)@JohnEstropia commented on GitHub (Nov 14, 2015):
@yoiang
Sorry, I just realized that the default
NSUndoManagerin iOS isnil, so you may need to create one and assign it totransaction.internalContext.undoManager. Another method is to recreate a new transaction withbeginUnsafe()every time the user tries to undo all changes.@yoiang commented on GitHub (Nov 14, 2015):
@JohnEstropia
Sounds good! If I notice a pattern with doing undo work with CoreStore that fits the CoreStore styling would you mind if I suggested a PR?
@JohnEstropia commented on GitHub (Nov 14, 2015):
@yoiang
I'd appreciate that! :)