@property (strong, nonatomic) NSMutableArray *speciesArray;
See my answer here:
https://stackoverflow.com/a/22748539/341994
And indeed, the facts are exactly the same. It is not enough to declare the class of something. That thing must actually be that class (polymorphism). An instance has a class (as an internal fact about it), quite without regard for how you may cast or declare a variable that merely refers to it.
You will thus find that, however you are actually making or obtaining this array, it is a non-mutable array (NSArray); merely claiming it is mutable, as you are doing, will not make it so. The facts have a power of their own.
EDIT: And so indeed it proved to be the case. You are say, in effect, this:
myArray = [[NSUserDefaults standardUserDefaults] objectForKey:@"stuff"];
Now myArray
is an immutable array, no matter how you declared myArray
. The fix is to do a mutableCopy
:
myArray = [[[NSUserDefaults standardUserDefaults] objectForKey:@"stuff"] mutableCopy];