- [__ NSCFDictionary JSONRepresentation]:发送到实例的无法识别的选择器

时间:2011-04-04 11:15:10

标签: iphone json nsdictionary

我正在使用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]; 

1 个答案:

答案 0 :(得分:3)

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

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