Re: Issues implementing [NSArrayController replaceObjectsAtArrangedObjectIndexes: withObjects:]
Re: Issues implementing [NSArrayController replaceObjectsAtArrangedObjectIndexes: withObjects:]
- Subject: Re: Issues implementing [NSArrayController replaceObjectsAtArrangedObjectIndexes: withObjects:]
- From: Keary Suska <email@hidden>
- Date: Tue, 25 Mar 2008 12:28:30 -0600
- Thread-topic: Issues implementing [NSArrayController replaceObjectsAtArrangedObjectIndexes: withObjects:]
on 3/25/08 1:15 AM, email@hidden purportedly said:
> Since NSArrayController does not have 'replace' functionality, I'm
> trying to implement my own for performance reasons. Problem is, I
> keep getting an exception when my code runs. Here is a code snippit:
>
> - (void) replaceObjectsAtArrangedObjectIndexes:(NSIndexSet*)indexes
> withObjects:(NSArray*)objects
> {
> [self willChange:NSKeyValueChangeReplacement valuesAtIndexes: indexes
> forKey:@"arrangedObjects"];
>
> NSMutableArray* currentObjects = [self
> mutableArrayValueForKey:@"arrangedObjects"];
> [currentObjects replaceObjectsAtIndexes:indexes withObjects:objects];
>
> [self didChange:NSKeyValueChangeReplacement valuesAtIndexes:indexes
> forKey:@"arrangedObjects"];
> }
>
> However, when [currentObjects replaceObjectsAtIndexes withObjects:] is
> called it throws this exception:
The short answer is that this approach is wrong in too many ways to
enumerate. In short, stick to the MVC pattern. Do this at the model level,
not the controller level. At the model level you can use essentially the
same code (but with naming changes).
Best,
Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden