This is probably an simple problem but would someone nice be able to give me a hint what is wrong in the following scenario, i just do not understand. I have a NSMutableArray "playerArray", which have objects "ZERO", "ONE", "TWO", THREE".
I am trying to remove the object at "row" but it does not work. Could it be so that it returns a immutable array as the exception seems to getting thrown because it doesn't respond to removeObjectAtIndex?
NSUInteger row = 1; // [indexPath row]; NSLog(@"playerArray:%@", playerArray); NSLog(@"row: %i", row); [playerArray removeObjectAtIndex:row];
The result is:
playerArray:(
ZERO,
ONE,
TWO,
THREE
)
2010-11-21 20:58:46.681 FamQuiz_v2[2166:207] row: 1
2010-11-21 20:58:46.682 FamQuiz_v2[2166:207] -[__NSArrayI removeObjectAtIndex:]: unrecognized selector sent to instance 0x5e3b9a0
2010-11-21 20:58:46.683 FamQuiz_v2[2166:207] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSArrayI removeObjectAtIndex:]: unrecognized selector sent to instance 0x5e3b9a0'
It looks like your array is not actually a NSMutableArray. Verify it by logging the class name:
NSLog(NSStringFromClass([playerArray class]));
or, check with:
if ([playerArray isKindOfClass: [NSMutableArray class]])
{
...
}
The error message indicates that playerArray is an instance of NSArray, not NSMutableArray. You cannot call removeObjectAtIndex on an instance of NSArray.
-[__NSArrayI removeObjectAtIndex:]: unrecognized selector sent to instance
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With