开发者

Exception throwing JSON supporting program in iphone

开发者 https://www.devze.com 2023-03-12 11:59 出处:网络
I downloaded JSON files. I added these files in project directory. But when I am runnig program I am getting an error which is...

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 view开发者_JS百科DidLoad 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.


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消