JSONValue ARC问题 [英] JSONValue ARC issue

查看:98
本文介绍了JSONValue ARC问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在iOS5中使用内置的JSON框架,但在尝试编译此代码时出现ARC问题:

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];

在iOS5中是否有相同的方法可以解决ARC问题?

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

ARC问题是:'NSString'没有可见的@interface声明选择器'JSONValue'

推荐答案

您获得的消息意味着没有方法 JSONValue NSString中声明'(绝对正确)。要使用内置的JSON序列化程序,请尝试以下方法:

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有关选项,请参阅 NSJSONSerialization 类。另请注意,结果也可以是 NSArray

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

这篇关于JSONValue ARC问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆