- [__ NSCFDictionary JSONRepresentation]:发送到实例的无法识别的选择器 [英] -[__NSCFDictionary JSONRepresentation]: unrecognized selector sent to instance

查看:99
本文介绍了 - [__ NSCFDictionary JSONRepresentation]:发送到实例的无法识别的选择器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 github上提供的json-famework 。我在项目中添加了项目的引用,在我的viewController中添加了一个头文件搜索路径和导入的JSON.h文件。我试图实现以下代码,它给了我这个错误,JSONRepresentation是一个无法识别的NSDictionary对象选择器。我在这种情况下做错了什么。请指导我。

I am using the json-famework available on github. I have added the reference for the project in my project, has added a header search path and imported JSON.h file in my viewController. I am trying to implement following code, where it gives me this error that JSONRepresentation is an unrecognized selector for NSDictionary object. Am I doing anything wrong in this case. Please guide me through.

NSDictionary * profileDictionary = [NSDictionary dictionaryWithObjects:[NSArray arrayWithObjects:user.userId, user.userVia, user.userName, user.firstName, user.lastName, user.emailId, user.contactNumber, user.gender, user.alternateNumber, user.weight, user.height, user.city, user.loginId, user.imageType, user.imageFileName, user.dob,nil] 
                                                               forKeys:[NSArray arrayWithObjects:@"Id", @"UserVia", @"UserName", @"FirstName", @"LastName", @"EmailID", @"ContactNumber", @"Sex", @"AlternateNumber", @"weight", @"Height", @"City", @"LoginId", @"ImageType", @"ImageFileName", @"DOB", nil]];



NSString *jsonString = [profileDictionary JSONRepresentation]; 


推荐答案

您是否已将.m文件编译为项目中好吧?

Have you compiled the .m file into your projct as well?

只包含.h文件只允许代码编译。如果没有编译.m文件,它将在运行时因您看到的错误而崩溃。

Just including the .h file only lets the code compile. Without the .m file compiled as well it will crash at runtime with the error you are seeing.

这篇关于 - [__ NSCFDictionary JSONRepresentation]:发送到实例的无法识别的选择器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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