I have this code:
if (self.leadObject != nil) {
[result addObject:self.leadObject];
}
And sometimes app close with this error:
* Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '* -[__NSArrayM insertObject:atIndex:]: object cannot be nil'
The execution pass if command and try to add the object self.leadObject inside of result array although this object is nil.
Can someone explain this??
Update:
* Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '* -[__NSArrayM insertObject:atIndex:]: object cannot be nil' *** First throw call stack: (0x2ca8af87 0x3a1e9c77 0x2c9a6f29 0x1777ff 0x177a6f 0x177b7f 0x1779df 0x17446d 0xa1cdd 0xa7933 0x46cad3 0x46cabf 0x47051b 0x2ca50e61 0x2ca4f581 0x2c99cdb1 0x2c99cbc3 0x33d28051 0x2ff68a31 0xadb45 0x3a785aaf) libc++abi.dylib: terminating with uncaught exception of type NSException
[result addObject:self.leadObject]where you print the value ofself.leadObject, just to make sure...insertObject:atIndex:somewhere?leadObjectif there is one, otherwise the ivar definition and the definition of the getter, if it is not synthesized.