Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS Build a Blog Reader iPhone App Getting Data from the Web Downloading and Parsing JSON Data

Daniel Sánchez
Daniel Sánchez
34,474 Points

NSCocoaErrorDomain Code=256 "The operation couldn’t be completed. (Cocoa error 256.)

I'm getting the following error Error Domain=NSCocoaErrorDomain Code=256 "The operation couldn’t be completed. (Cocoa error 256.)" UserInfo=0x7febbb53b4f0 {NSURL=http://blog.teamtreehouse.com/api/get_recent_summary/} when i run my project with this code:

NSURL *blogURL = [NSURL URLWithString:@"http://blog.teamtreehouse.com/api/get_recent_summary/"];
NSError *error = nil;
NSData *jsonData = [NSData dataWithContentsOfURL:blogURL options:0 error:&error];
NSLog(@"%@",error);
NSDictionary *dataDictionary = [NSJSONSerialization JSONObjectWithData:jsonData options:0 error: &error];
self.blogPost = [dataDictionary objectForKey:@"posts"];

Somebody can help me?

1 Answer

First of all, stick with dataWithContentsOfURL rather than adding options and error. Second of all, NSLog can't print error.