Looks like your [jsonDict objectForKey:@"id"]
is an NSNumber
(or NSDecimalNumber
) and not an NSString
. You should change the line NSString *IDID = [jsonDict objectForKey:@"id"];
to,
id myObject = [jsonDict objectForKey:@"id"];
NSString *IDID = nil;
if ([myObject isKindOfClass:[NSNumber class]]) {
IDID = [[jsonDict objectForKey:@"id"] stringValue];
} else {
IDID = [jsonDict objectForKey:@"id"];
}
This error appeared now since earlier you were not initializing NSMutableString *yolo
and you were using appendString:
on a nil object. Since now it is initialized as NSMutableString *yolo = [[NSMutableString alloc] init];
it is trying to call appendString
on NSMutableString
object which accepts only NSString
type as its inputs where as you are passing an NSNumber
in it. length
is a method which appendString:
internally calls. So you need to change this as well.