i am getting unpredictable error when two of NSMutableArray having same value at index 0 then i want to remove that object and replace object with empty string. But app get crash saying
-[__NSArrayI replaceObjectAtIndex:withObject:]: unrecognized selector sent to instance 0xe2a06b0
2012-03-22 14:36:48.181 golf eScorer[3849:11f03] *** Terminating app due to uncaught exception
'NSInvalidArgumentException', reason: '-[__NSArrayI replaceObjectAtIndex:withObject:]:
unrecognized selector sent to instance 0xe2a06b0'
When i debug using break point than log shows
2012-03-22 14:36:44.548 golf eScorer[3849:11f03] ArrayOfGameidOfPlayerToRemove....(
2
)
2012-03-22 14:36:44.549 golf eScorer[3849:11f03] discardedId...(
2
)
Here is my line of code:
if([[ArrayOfGameidOfPlayerToRemove objectAtIndex:0] isEqualToString:[discardedId
objectAtIndex:0]])
{
[ArrayOfGameidOfPlayerToRemove replaceObjectAtIndex:0 withObject:emptyString];
}
Update:
I solved like this
NSMutableArray *ArrayOfGameidOfPlayerToRemove = [yournsarray mutableCopy];
It seems the variable
ArrayOfGameidOfPlayerToRemoveis instance ofNSArray. You can replace object in only inNSMutableArray