I have a JSON feed of articles with 10 articles per page. JSON structure is something like this
{
"total_entries": 150,
"next_page": "http://localhost/?page=2",
"entries": [{"title": "Title 1"}, {"title": "Title 2"}],
"per_page": 10
"current_page": 1
}
I want to show the titles in UITableView
and when you scroll down, the app should fetch articles from the next page.
Right now I'm fetching the first 10 articles in viewDidLoad. The pagination logic, if I understand it correctly, should happen in
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
What's the best way to structure such an app? Should I store all articles that I get from JSON in memory? Then it can be up to 150 NSDictionary
objects, all of them are pretty small though. Or should I save articles in sqlite or core data? Are there any examples of dealing with UITableView
and paginated lists that come from a web service?
great example of parsing XML from webservices is SeismicXML from Apple
https://developer.apple.com/library/content/samplecode/SeismicXML/Introduction/Intro.html
and I found another one for you - iPhone JSON Flickr Tutorial
http://iosdevelopertips.com/networking/iphone-json-flickr-tutorial-part-1.html
this is rather old (2009) but hope it helps to figured it out ^)d