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

Scott Fitsimones
Scott Fitsimones
2,609 Points

When I use your URL the JSON parsing works great, but other URLs like: http://bit.ly/1rA2jYI don't work.

This URL: http://ajax.googleapis.com/ajax/services/feed/load?v=2.0&q=http://rss.cnn.com/rss/edition.rss&num=20

Should allow me to pull CNN, and it comes up in the JSON Viewer chrome plugin so I know it is valid, but when I paste it in in xCode it doesn't work. I have been using the key: "entries"

2 Answers

Robert Bojor
PLUS
Robert Bojor
Courses Plus Student 29,439 Points

If you take a closer look at the JSON that comes back from the feed link, you will notice that the root key is responseData which contains the key feed and then entries. So what you'll need to use is [@"responseData"][@"feed"][@"entries"] ( Screenshot here: https://www.dropbox.com/s/tks6tngyjme4o0c/Screenshot%202014-07-25%2011.39.55.png)

As to your question in the title about links from bit.ly, as well as other link shorteners for that matter, the actual call that you make is first to the shortener's server, which in turn will redirect your browser to the destination link. In the browser this works without you noticing anything but I believe in Xcode it will not work, you need to point Xcode to the real URL.

try the key "feed.entries"