【问题标题】:-[__NSCFDictionary JSONRepresentation]: unrecognized selector sent to instance-[__NSCFDictionary JSONRepresentation]:无法识别的选择器发送到实例
【发布时间】:2011-04-04 11:15:10
【问题描述】:

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

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

【问题讨论】:

    标签: iphone json nsdictionary


    【解决方案1】:

    您是否也将 .m 文件编译到您的项目中?

    仅包含 .h 文件只会让代码编译。如果没有编译 .m 文件,它将在运行时崩溃并出现您看到的错误。

    【讨论】:

    • 我将源中的所有类文件添加到项目中并运行应用程序。现在似乎工作正常。感谢 deanWombourne 的帮助。
    猜你喜欢
    • 2013-03-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-08-28
    • 2012-07-24
    相关资源
    最近更新 更多