1

I downloaded JSON files. I added these files in project directory. But when I am runnig program I am getting an error which is...

-[__NSCFDictionary JSONRepresentation]: unrecognized selector sent to instance 0x6003d50

* Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFDictionary JSONRepresentation]: unrecognized selector sent to instance 0x6003d50' * Call stack at first throw:

I imported header file #import "JSON/JSON.h" and I wrote jsocn code in viewDidLoad function which is like below...

NSDictionary *requestData = [NSDictionary dictionaryWithObjectsAndKeys:
                             @"grio", @"username",
                             @"hellogrio", @"password",
                             nil];

NSString* jsonString = [requestData JSONRepresentation];

NSLog(@"%@", jsonString);

Kindly help me.

Thanks in advance.

Nick Weaver
  • 47,228
  • 12
  • 98
  • 108
Ajay_Kumar
  • 1,381
  • 10
  • 34
  • 62

2 Answers2

2

I am guessing you are using json-framework. You probably forgot to add -all_load to the linker flags. See this question for more details.

Community
  • 1
  • 1
freespace
  • 16,529
  • 4
  • 36
  • 58
  • I only added JSON supported files in my project directry by copy and paste. I did not add any frameowrk yet. Should I add ? If yes then please know what and how will i add framework ? I am using Xcode4. – Ajay_Kumar Jun 10 '11 at 09:21
  • Should you add -all_load? Yes. – freespace Jun 10 '11 at 09:41
1

It's not clear from your question which JSON implementation you're using, but the error means that you're sending the JSONRepresentation message to an NSDictionary. The dictionary does not understand the message and raises an exception.

It seems that either you're not using the JSON library correctly or that you have not installed it correctly in your project.

Stephen Darlington
  • 51,577
  • 12
  • 107
  • 152