iPhone中JSON支持程序抛出异常
我下载了 JSON 文件。我将这些文件添加到项目目录中。但是当我运行程序时,我收到一个错误...
-[__NSCF字典 JSONRepresentation]:无法识别 选择器发送到实例 0x6003d50
* 由于未捕获的异常而终止应用程序 'NSInvalidArgumentException',原因: '-[__NSCF字典 JSONRepresentation]:无法识别 选择器发送到实例 0x6003d50' *第一次抛出时的调用堆栈:
我导入了头文件 #import "JSON/JSON.h"
并在 viewDidLoad 函数中编写了 jsocn 代码,如下所示......
NSDictionary *requestData = [NSDictionary dictionaryWithObjectsAndKeys:
@"grio", @"username",
@"hellogrio", @"password",
nil];
NSString* jsonString = [requestData JSONRepresentation];
NSLog(@"%@", jsonString);
请帮助我。
提前致谢。
I downloaded JSON files. I added these files in project directory. But when I am runnig program I am getting an error which is...
-[__NSCFDictionary
JSONRepresentation]: unrecognized
selector sent to instance 0x6003d50* Terminating app due to uncaught exception
'NSInvalidArgumentException', reason:
'-[__NSCFDictionary
JSONRepresentation]: unrecognized
selector sent to instance 0x6003d50'
* Call stack at first throw:
I imported header file #import "JSON/JSON.h"
and I wrote jsocn code in viewDidLoad function which is like below...
NSDictionary *requestData = [NSDictionary dictionaryWithObjectsAndKeys:
@"grio", @"username",
@"hellogrio", @"password",
nil];
NSString* jsonString = [requestData JSONRepresentation];
NSLog(@"%@", jsonString);
Kindly help me.
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我猜您正在使用
json-framework
。您可能忘记将-all_load
添加到链接器标志中。有关更多详细信息,请参阅此问题。I am guessing you are using
json-framework
. You probably forgot to add-all_load
to the linker flags. See this question for more details.从您的问题中不清楚您正在使用哪种 JSON 实现,但该错误意味着您正在将
JSONRepresentation
消息发送到NSDictionary
。字典无法理解该消息并引发异常。看来您没有正确使用 JSON 库,或者没有在项目中正确安装它。
It's not clear from your question which JSON implementation you're using, but the error means that you're sending the
JSONRepresentation
message to anNSDictionary
. The dictionary does not understand the message and raises an exception.It seems that either you're not using the JSON library correctly or that you have not installed it correctly in your project.