I hope the word "Raiseman" does not cause too many eyes to roll (
) but this is continuing the quest for Cocoa.
For those unfamiliar with Raiseman, the app is document-based, with an TableView, each of whose columns is bound to an attribute of an object in an MutableArray, all through an ArrayController.
One of the methods in MyDocument.m is this.
One of the things that I am puzzled about is the line
Hillegass says that this method is called automatically when NSArrayController wishes to insert or remove (Person) objects. (The app has an "Insert New Employee" and "Delete Employee" button, which target the controllArray's add and remove actions).
So, please excuse the very dumb question. When is this method called such that the ![undo isUndoing] returns TRUE and when does it return FALSE. I suspect the reason I am asking this is a lack of a complete conceptual understanding of how this is working.
Thanks in advance.
For those unfamiliar with Raiseman, the app is document-based, with an TableView, each of whose columns is bound to an attribute of an object in an MutableArray, all through an ArrayController.
One of the methods in MyDocument.m is this.
Code:
-(void) insertObject: (Person *) p inEmployeesAtIndex: (int) index
{
NSLog(@"Adding %@ to %@", p, employees);
NSUndoManager *undo = [ self undoManager];
[[undo prepareWithInvocationTarget:self] removeObjectFromEmployeesAtIndex:index];
if ( ![undo isUndoing])
[undo setActionName:@"Insert Person"];
[employees insertObject: p atIndex:index];
NSLog(@"Done adding person");
}
One of the things that I am puzzled about is the line
if ( ![undo isUndoing])......
Hillegass says that this method is called automatically when NSArrayController wishes to insert or remove (Person) objects. (The app has an "Insert New Employee" and "Delete Employee" button, which target the controllArray's add and remove actions).
So, please excuse the very dumb question. When is this method called such that the ![undo isUndoing] returns TRUE and when does it return FALSE. I suspect the reason I am asking this is a lack of a complete conceptual understanding of how this is working.
Thanks in advance.