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 Adapting Data for Display Handling Malformed Data

Tucker Sherman
Tucker Sherman
3,746 Points

bug in project somewhere near NSJSONSerialization?

iOS newbie question here - I have been working through the blog reader app project and everything has been working great until I created a custom class (stage4) now every time I run my app it crashes in tableViewController.m at

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

with the error "Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'data parameter is nil' "

I had a similar error earlier in the project when I made a typo in the URL but I have triple checked my syntax and haven't found any issues... To be sure I downloaded the project files for stage 5 (complete with exceptions for empty JSON data fields), ran them and it looks like the app is still crashing at exactly the same spot. This leads me to believe it is something different about xcode6 and JSON Serialization ? I've been reading through the apple documentation all morning and haven't found anything - although to be honest I am not entirely sure what I am looking for... Stumped, maybe I have missed something obvious but any pointers as to where/what to look for would be greatly appreciated!

1 Answer

Tucker Sherman
Tucker Sherman
3,746 Points

AHA

Figured it out - for anyone else having a similar problem it seems like there was something wrong with my iOS Simulator - when I tested the app on a device it was able to parse the data with no problems, so I tried quitting my iOS simulator and re-running the app and magically everything is fine... Apologies to the users who I asked!

donj808
donj808
8,514 Points

Thanks. That did the trick for me as well.

Benjamin McMahan
Benjamin McMahan
6,679 Points

Likewise here. Restarting the simulator worked it out. Wasted some time trying to figure that out