Waitak Jong Waitak Jong - 5 months ago 15
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

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