1) Almost, but not quite. If you think that your application code is divided into three areas: Model, View and Controller ( as described here ), then the Cocoa / XCode environment provides you with a โcodelessโ way of handling the basics of each: IB for presentation, basic data for the model and controllers Bindings / Object for the controller.
Cancellation of control is primarily associated with the model, and not with the view or controller. So itโs not Bindings or the task of an object controller to manage this stuff. It seems your problem is that you are using arrays as your data objects that are too easy to process this stuff. If you want to refuse support, you will want to use the basic data to process the model and provide these materials for free or manually create your own model objects (which will likely contain arrays) that process this logic.
FWIW, once you do this, bindings will indirectly make your life much easier, because when the cancel command returns your data to its previous state, the view will automatically reflect the changes.
In addition, the name NSArrayController is a bit misleading - it does not exist for "array management". This is true for managing data objects that are โmanyโ related to other data objects. Which led me to ...
2) KVC allows you to relate to many relationships between an object and other objects as an array or set, regardless of how the relationships are actually implemented. It does this by requiring you to implement methods of setting up a naming convention that matches very closely the primitive methods of arrays and sets . KVC compatible objects return a proxy array or set when mutableArrayValueForKey: or mutableSetValueForKey: , which provides these methods as an array. Roughly speaking, NSArrayController knows what to call --- KVC cards between primitive array objects and some methods whose manes it generates from the key. Since you do not want to use arrays as data objects, it is usually very useful to be able to handle all-many relationships as if it were just a regular collection.
3) I think this is due to the fact that you cancel the wrong place. Introduce methods compatible with KVC to get / set properties in your data objects, make them update undoManger at the same time as setting up the data. You will need a special method when the non-non-camera will need to cancel the changes, since you do not want the cancellation to be recorded as canceled. Or you can just use Core Data and get it all for free ...
source share