Ok boys and girls, this is my prob :
I'd like to read a JSON stream in my iOS app, but when i tried, it returns
2013-04-12 02:35:01.479 Test[81414:303] (null)
but my file exist and is absolutely not empty !! You can find it here http://api.kalokod.com/cce/mainfeed.json
And my script to read it is :
NSError *error;
NSURL *file = [NSURL URLWithString:@"http://api.kalokod.com/cce/mainfeed.json"];
NSString *string = [NSString stringWithContentsOfURL:file
encoding:NSUTF8StringEncoding
error:&error];
NSLog(@"%@", string);
I tested your code, and received a Cocoa Error 261
. This means that the JSON you are trying to load isnt encoded with UTF-8, so using NSUTF8StringEncoding
wont work. Try this
NSString *string = [NSString stringWithContentsOfURL:file
encoding:NSASCIIStringEncoding
error:&error];