Search code examples
iosxcodefacebooksdksbjson

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


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.


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.