- [__ nscfdictionary jsonrementation]:未识别的选择器已发送到实例
我正在使用 github 上提供的 json-famework。我在我的项目中添加了该项目的引用,在我的 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];
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];
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否也将 .m 文件编译到您的项目中?
仅包含 .h 文件只能让代码编译。如果没有编译 .m 文件,它将在运行时崩溃并出现您所看到的错误。
Have you compiled the .m file into your projct as well?
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.