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

reardelt
reardelt
8,030 Points

Getting "null" when logging the NSData object.

My code is shown here, http://paste.ofcode.org/Fg3ftS3nsZT4RMMrvErCvJ

When I NSLog the NSData object, I get null, I believe I have the url correct. What could be the issue?

2 Answers

Dan Paschevici
Dan Paschevici
4,013 Points

Try to add between NSData and NSLog this 2 lines of code:

NSError *error = nil; NSDictionary *data = [NSJSONSerialization JSONObjectWithData:theData options:0 error:&error];

And you make an NSLog to retrieve "data" ( NSLog(@"%@", data); )

reardelt
reardelt
8,030 Points

Hi Dan, That is giving me an error as well because NSData is null and it can't serialise a null object.

Benjamin McMahan
Benjamin McMahan
6,679 Points

Did you ever resolve this? I can't get past this part, same problem. I am using the exact code as in the video and the URL is valid, I even tested others.

reardelt
reardelt
8,030 Points

I think I skipped this part if I remember correctly