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: