JSONValue ARC issue

前端 未结 1 1961
庸人自扰
庸人自扰 2020-12-20 22:09

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]         


        
相关标签:
1条回答
  • 2020-12-20 23:10

    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.

    0 讨论(0)
提交回复
热议问题