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

json data

hai, i couldnt run the json first programe under downloading and parsing json data....

no errors showing when i start compiling..but during compilation shows the below error... "terminating with uncaught exception of type NSException..."

can you help me.....

10 Answers

Thomas Nilsen
Thomas Nilsen
14,957 Points

Your mistake is writing "@jsondata". looking back at the project it's supposed to be something like this:

NSURL *blogURL = [NSURL URLWithString:@"http://blog.teamtreehouse.com/api/get_recent_summary/"];

    NSData *jsonData = [NSData dataWithContentsOfURL:blogURL];

    NSError *error = nil;

    NSDictionary *dataDictionary = [NSJSONSerialization JSONObjectWithData:jsonData options:0 error:&error];
Thomas Nilsen
Thomas Nilsen
14,957 Points

Try adding an exception breakpoint - and run the code again :) That should show you the line that's causing problems.

Thanks....

Yes, I did....but,It is showing the same error. ...

Thomas Nilsen
Thomas Nilsen
14,957 Points

If it points to a line in your code, do you mind pasting it in here so we can have a look?

Actually I am running the whole code.... how can I add an " exception breakpoint "....sorry I dont know about it...

I added break points at the starting of json data link declaration ....while running its juz showing" breakpoint 1.1" on a green line

Thomas Nilsen
Thomas Nilsen
14,957 Points

do it like this, and run the code again:

http://imgur.com/rPEqP3l

NSDictionary *blogspot = [NSJSONSerialization JSONObjectWithData:@"jsondata" options:0 error:&error];

pointing this line

couldnt see full code.... can you please paste it fully

Thomas Nilsen
Thomas Nilsen
14,957 Points

like so:

NSURL *blogURL = [NSURL URLWithString:@"http://blog.teamtreehouse.com/api/get_recent_summary/"];

NSData *jsonData = [NSData dataWithContentsOfURL:blogURL];

NSError *error = nil;

NSDictionary *dataDictionary = [NSJSONSerialization JSONObjectWithData:jsonData options:0 error:&error];

Finally it works :-)

thank you so much