As others have said, NSMutableArray
can only contain Objective-C objects. They do not have to be subclasses of NSObject
, but that is the most typical.
However, long before you ever see the attempt to insert nil.
runtime error, you should have seen a compiler warning:
warning: passing argument 1 of 'addObject:' makes pointer from integer without a cast
It is [in a vague and roundabout way] telling you exactly what the problem is; you are trying to stick something into an array that is not a pointer [to an object].
Pay attention to warnings and fix them. Most of the time, the presence of a warning will indicate a runtime error or crash.