Can't parse json Data via YAJLiOS
ios, iphone, objective-c, xcode, yajl
Solution
According to the YAJL documentation the method you are trying to invoke does in fact exist.
That leaves only one option; you have not fully linked against the YAJL framework.
Make sure it shows up within the list of linked frameworks/libraries of your App target just like `CFNetwork.framework` shows up in my example.
Since the method you are trying to invoke is in fact part of a category on `NSData`, make sure you include `-ObjC` in your Other Linker Flags.
From Apple's Technical Q&A.
This flag causes the linker to load every object file in the library that defines an Objective-C class or category. While this option will typically result in a larger executable (due to additional object code loaded into the application), it will allow the successful creation of effective Objective-C static libraries that contain categories on existing classes.
Problem
At first i'm trying to access local file in my app folder: ``` NSData *data = [NSData dataWithContentsOfFile: [@"countries.json" stringByExpandingTildeInPath]]; ``` result is always NULL then i tried to check is file exists: ``` NSString* documentsPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]; NSString* foofile = [documentsPath stringByAppendingPathComponent:@"countries.json"]; BOOL fileExists = [[NSFileManager defaultManager] fileExistsAtPath:foofile]; ``` it doesn't exist, and i use following code to access my json file: ``` NSString *data1 = [[NSBundle mainBundle] pathForResource:@"countries" ofType:@"json"]; NSData *data2 = [[NSData alloc] initWithContentsOfFile:data1]; ``` it getting the file but when i try to parse it: ``` NSDictionary *dict1 =[data2 yajl_JSON]; ``` i getting an error: ``` [NSConcreteData yajl_JSON]: unrecognized selector sent to instance 0x6838d60 ``` My questions is next: Is there any chance 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: