Unable to parse json data via YAJLiOS

First I try to access the local file in my application folder:

    NSData *data = [NSData dataWithContentsOfFile:
                                      [@"countries.json" stringByExpandingTildeInPath]];

the result is always NULL

then I tried to check if the file exists:

    NSString* documentsPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
    NSString* foofile = [documentsPath stringByAppendingPathComponent:@"countries.json"];
    BOOL fileExists = [[NSFileManager defaultManager] fileExistsAtPath:foofile];

it does not exist, and I use the following code to access my json file:

    NSString *data1 = [[NSBundle mainBundle] pathForResource:@"countries" ofType:@"json"];
    NSData *data2 = [[NSData alloc] initWithContentsOfFile:data1];

it gets the file, but when I try to parse it:

    NSDictionary *dict1 =[data2 yajl_JSON];

I get an error message:

    [NSConcreteData yajl_JSON]: unrecognized selector sent to instance 0x6838d60

My questions are as follows :

  • Is it possible to convert NSData to NSConcreteData?

  • Am I using the right approach to access data?


Api Documentation - http://gabriel.github.com/yajl-objc/

Screenshot of my Xcode build phases:

enter image description here

+3
source share
1 answer

YAJL , , .

; YAJL.

, / , , CFNetwork.framework .

enter image description here

, , NSData, , -ObjC .

enter image description here

Apple Technical Q & A.

Objective-C. (- ), Objective-C, .

+2

All Articles