Issues implementing [NSArrayController replaceObjectsAtArrangedObjectIndexes: withObjects:]
Issues implementing [NSArrayController replaceObjectsAtArrangedObjectIndexes: withObjects:]
- Subject: Issues implementing [NSArrayController replaceObjectsAtArrangedObjectIndexes: withObjects:]
- From: Rob Petrovec <email@hidden>
- Date: Tue, 25 Mar 2008 00:15:21 -0700
Hey,
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:
-[_NSControllerArrayProxy replaceObjectsAtIndexes:withObjects:]:
unrecognized selector sent to instance 0x1e4ccf0
0x1e4ccf0 is the address 'currentObjects' points to. I've verified
that 'objects' and 'currentObjects' contain the correct data and that
the indexes being passed in are in the correct range. I also verified
(via [currentObjects isKindOfClass:[NSMutableArray class]]) that
'currentObjects' is in fact an NSMutableArray. I'm creating the
NSArrayController programmatically via [[NSArrayController alloc]
initWithContent:nil] and adding objects to it via [NSArrayController
addObject]. Essentially using the internal NSArray of the
NSArrayController as my data source. Everything displays/updates
correctly etc, it just balks on this block of code. Am I doing
something wrong? Is there a better way to do this? Any ideas?
Thanks in advance...
_______________________________________________
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