Dyldo42
Dyldo42

Reputation: 2348

NSMutableArray 'addObject:' Crashing iPhone App

This is my error:

Terminating app due to uncaught exception 'NSInvalidArgumentException', 
reason: '-[__NSArrayI addObject:]: unrecognized selector sent to instance

I have no idea why this is happening. Both the array (which is NSMutableArray) and the object being added are definitely not nil, and the @property for the array is straight up (nonatomic, retain).

Can anyone help?

Upvotes: 0

Views: 1595

Answers (1)

user189804
user189804

Reputation:

Chances are the array is not a NSMutableArray - a NSArray is not mutable, that is, you cannot add objects to it.

I know you said it is - but if you do

NSMutableArray* someArray = [NSArray array];

you get a NSArray, not a NSMutableArray. I've done it.

Upvotes: 3

Related Questions