SBJson and Facebook iOS SDK error “no visible @interface for 'NSData' declares the selector 'JSONValue'”

StackOverflow https://stackoverflow.com/questions/11835104

Question

I get an error saying:

"no visible @interface for 'NSData' declares the selector 'JSONValue'" ??

It happens when I have a data stream (NSDAta) NSDictionary * dict = [data JSONValue];

I have only the SBJson files that came with the facebook SDK. Can someone help me understand what is happening.

Was it helpful?

Solution

Your "data" should actually be a "NSString" object.

Then you can do something like this (assuming the JSON data is in the variable named "data"):

NSString *json_string = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; 
if(json_string)
{
    NSDictionary * facebookDict = [json_string JSONValue];
}

Also make sure you "#import "NSString+SBJSON.h"" at the top of the .m file this code lives in.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top