NSArrayController and undo row add/remove
NSArrayController and undo row add/remove
- Subject: NSArrayController and undo row add/remove
- From: Ashley Clark <email@hidden>
- Date: Mon, 26 Apr 2004 00:46:42 -0500
I've been experimenting with the Controller objects and trying to
implement undo support with them and run up against a snag. I've
subclassed NSArrayController so I can get at the document's
undoManager. This seemed like a good place to register the addition and
removal of rows with the undo manager but it doesn't seem to be
working.
- (void)addObject:(id)object {
[[[document undoManager] prepareWithInvocationTarget:self]
removeObject:object];
[super addObject:object];
}
- (void)removeObject:(id)object {
[[[document undoManager] prepareWithInvocationTarget:self]
addObject:object];
[super removeObject:object];
}
Now, I've got two buttons bound to add: and remove: of my subclassed
ArrayController. When I add a row it adds an entry to the undo stack to
remove the row but if I remove a row, no entry is added. Obviously my
method's not being called. What appears to be called is
removeObjectsAtArrangedObjectIndexes. But even what it does seems
inconsistent, sometimes it calls removeObjectAtArrangedObjectIndex and
other times, I don't know what it does, it just seems to magically
remove the items. Any ideas on what to override or am I looking in the
wrong place?
Ashley Clark
[demime 0.98b removed an attachment of type application/pkcs7-signature which had a name of smime.p7s]
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.