Waitak Jong Waitak Jong - 1 year ago 77
iOS Question

why adding string to NSMutableArray not work?

why adding string to nsmuarray not work?
firstly, i add the a NSDictionary by keypath to the NSMutableArray,
its work.
after that i want to add one more string to that but its not work.

NSMutableArray *_joinornot;

_joinornot = [[NSMutableArray alloc] init];

NSDictionary *tempobject = [[NSDictionary alloc] init];

_joinornot = [tempobject valueForKeyPath:@"groupid"];

until now everything work.

[_joinornot addObject:@"111"];<----unrecongnized selector sent to instance

Answer Source

if _joinornot = [tempobject valueForKeyPath:@"groupid"]; returns nil, then your array will be nil, and then you cant call addObject. so maybe add a nil check

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download