Vaibhav Tekam
Vaibhav Tekam

Reputation: 2344

-[__NSCFDictionary JSONRepresentation]: unrecognized selector sent to instance

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

Upvotes: 3

Views: 2800

Answers (1)

deanWombourne
deanWombourne

Reputation: 38475

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.

Upvotes: 3

Related Questions