At this point, four smart people (not including me) indicated that you are sending -removeObjectAtIndex: object that considers it an immutable array. This would be a good time to start wondering why the array is immutable when you considered it volatile. If you post code that shows how the array is created, someone here will probably be able to show you what is going wrong.
One way you can get an immutable array when you think you have a mutable is to copy the modified array. For example, you might have a property:
@property (copy) NSMutableArray *myArray;
Perhaps you will then create a mutable array, add some objects and assign it to your property:
NSMutableArray *tempArray = [NSMutableArray array]; [tempArray addObject:@"You say goodbye"]; [tempArray addObject:@"I say hello"]; self.myArray = tempArray;
Now, does tempArray point to a mutable array or an immutable array? I have not tested recently, but I'm sure you will get an immutable array. You will definitely get an immutable array if you say:
NSMutableArray *foo = [tempArray copy];
So, start looking for places in the code where your array pointer is reassigned. After all, if your pointer really pointed to a mutable array, it would be terribly difficult to explain the exception you are getting.
source share