I'm trying to write a Facebook Feed app for iOS, and I'm trying to use the JSON framework, to little effect. Whenever I run my code, I get the error "* Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'data parameter is nil'". I'm using a feed from Flickr as a test/demonstration URL, as the Facebook URL is programmatically created using an Access Token request and appendToString:.
NSURL *url2 = [NSURL URLWithString:@"www.flickr.com/services/feeds
/photos_public.gne?tags=punctuation&someKey=atsign&format=json"];
NSError *error = nil;
NSData *data = [NSData dataWithContentsOfURL:url2];
if (data == nil){
NSLog(@"data is nil");
}
NSDictionary *json = [NSJSONSerialization JSONObjectWithData:data
options:NSJSONReadingMutableContainers
error:nil];
NSLog(@"json: %@\n\n Or Error: %@", json, [error localizedDescription]);
EDIT: I changed my code around to include an error and an NSlog, and changed the URL (on the advice of the poster ilis), as well as adding an if statement to test if data is nil (thanks to poster Dustin for the idea). Now I get an output from the NSLog that states "json: (null) Or Error: The operation couldn't be completed. (Cocoa error 3840.)", and no response from the if statement. So I think the problem is arising when NSDictionary json is being created.