Re: NSArrayController and undo row add/remove
Re: NSArrayController and undo row add/remove
- Subject: Re: NSArrayController and undo row add/remove
- From: Don Briggs <email@hidden>
- Date: Mon, 26 Apr 2004 06:50:27 -0700
Hello, Ashley
There's an example project on my .Mac hompeage:
http://homepage.mac.com/donbriggs
Look for the "ToManyDemo".
It's a document-based application, and each document supports a table.
It's undoable and AppleScriptable.
(Two of the columns of the table, the name and ID, are constrained to
be unique per document.
If that's overkill for you, just use the "ToMany" class instead of its
"ToManyUniqueByKeys" subclass.)
In writing this example, I also tried subclassing NSArrayController,
then rejected that approach.
All best,
Don
On Apr 25, 2004, at 10:46 PM, Ashley Clark wrote:
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.
_______________________________________________
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.