Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JSONValue ARC issue

Im trying to use the built in JSON framework in iOS5, but i get an ARC issue when trying to compile this code:

NSDictionary *results = [jsonString JSONValue];

Is there an equivalent way to do this in iOS5, that doesn't raise an ARC issue?

ARC issue is: No visible @interface for 'NSString' declares the selector 'JSONValue'

like image 554
Lahib Avatar asked Apr 12 '12 11:04

Lahib


1 Answers

The message you get means 'There is no method JSONValue declared in NSString' (which is absolutely true). In order to use the built in JSON serializer try this one:

NSError *error;
NSData *jsonData = [jsonString dataUsingEncoding:NSUTF8StringEncoding];
NSDictionary *results = [NSJSONSerialization JSONObjectWithData:jsonData options:0 error:&error];

Ps For options see the documentation on NSJSONSerialization class. Also note that results can be an NSArray as well.

like image 171
Alladinian Avatar answered Nov 05 '22 14:11

Alladinian