I have a mutable array of detail objects and a UICollectionView populated with cells representing them. When you tap on a cell, it bring up a detail view on that object with a few options you can change about the object. It also includes three buttons, each of which should dismiss the detail view:
- Cancel
- Done
- Delete
If the cancel button is pressed, any changes the user made to the object should be discarded and it'll be if the user never brought up the detail view.
If the done button is pressed, any changes the user made to the object should be made permanent.
If the delete button is pressed, the object should be removed from the array.
Here's my actual question: should the detail view edit the object itself, or a duplicate of the object or something else? If it's working on a duplicate of the object, that would require the main view to keep track of the index of the selected object, so that it can remove the object if it's deleted, or it can replace the object if the done button is pressed. If it's working on the actual object, that means somewhere the original state of the object will need to be preserved so that any edits can be rolled back.
Neither of the options seem right to me. I feel like there's some better option that hasn't come to me. Which option would you use? I'm reluctant to use Core Data just because it seems like it tends to make things much more complicated than necessary I'm not dealing with many objects I expect the array will have perhaps a dozen objects in it at most most users will probably only have 4 or so.
- Cancel
- Done
- Delete
If the cancel button is pressed, any changes the user made to the object should be discarded and it'll be if the user never brought up the detail view.
If the done button is pressed, any changes the user made to the object should be made permanent.
If the delete button is pressed, the object should be removed from the array.
Here's my actual question: should the detail view edit the object itself, or a duplicate of the object or something else? If it's working on a duplicate of the object, that would require the main view to keep track of the index of the selected object, so that it can remove the object if it's deleted, or it can replace the object if the done button is pressed. If it's working on the actual object, that means somewhere the original state of the object will need to be preserved so that any edits can be rolled back.
Neither of the options seem right to me. I feel like there's some better option that hasn't come to me. Which option would you use? I'm reluctant to use Core Data just because it seems like it tends to make things much more complicated than necessary I'm not dealing with many objects I expect the array will have perhaps a dozen objects in it at most most users will probably only have 4 or so.