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
Adhish Chugh
Courses Plus Student 1,889 PointsGoing further with the BlogReader project
I am making my iOS app which is mostly based on the BlogReader project but I need some changes in it. Like, I could store the content of the post and display it as HTML. I don't want them to open the website all the time, i.e, I want offline viewing. But when an internet connection IS available, it should update the content.
I was wondering how I could achieve that. If you could give me a little guidance on this topic, it'll be really helpful. I have just began to learn iOS Development. Thank you.
1 Answer
Ben Jakuben
Treehouse TeacherYou will want to request the page using its URL, and then use store the HTML response in an NSData object using the dataWithContentsOfURL method, like this answer from StackOverflow: http://stackoverflow.com/a/5607132/475217
That answer also shows how to store the HTML for offline use. There are other options as well, like NSUserDefaults or NSArchiver. NSUserDefaults is a simple way to get started. Here is another example from StackOverflow: http://stackoverflow.com/a/8727555/475217