IOS: checking for remote file updates

I have several UITableViews that collect their contents from deleted XML files. Sometimes a file is updated, but the view is not updated because I load the file into my viewDidLoad method.

I assume that I should do a validation in viewDidAppear and load the XML file again. But I do not want it to load every time the user clicks on this view.

What is the best way to do this? Can I somehow check the updated date of the deleted file on the Internet? Or should I save the updated date in my application and then check at intervals? There should be a preferred way to do this, so that I know that the XML file has been updated.

Thanks.

+4
source share
5 answers

I suggest making a request for a page with very little overhead, only with the data needed to check if the version has changed.

In the iOS app, save the last version value that you saved, and check it on this small page that you pull out. If the value on the page is larger (newer), then pull out the full XML file.

This version value can be either updated or updated version number. I'm currently not on a Mac, so testing the Obj-C code is not trivial, but here is some pseudo code:

int versionNumber; // can be a datetime as well ... void pullXmlIfAvailable() { int latestVersionNumber = parseVersionNumberFromPage(URLget("myurl.com/check.xml")).to_i(); if (latestVersionNumber > versionNumber) DataClass xml = parseDataFromLargerFile(URLget("myurl.com/bigfile.xml")); } 
0
source

Perhaps you can download the latest data directly, as your application is brought to the background (found in your application deletion).

parameter for this:

  • Save the data object in the application delegation class and reference it in the controller containing your UITableView . When your view controller calls viewDidAppear , just call reloadData your UITableView .
0
source

Instead of asking the server for the version number or update date, why not tell the server the version number or update date of your remote (client) version.

Your server then decides if you already have an existing version (A), or if you need a new one (B):

0
source

Other answers have already covered the “when to reload” file quite well.

Another thing to consider is to use the “pull to refresh” metaphor, which is very common in tableview applications these days, as it gives users the ability to see both when the data was last updated and immediately request it.

See iPhone Pull Down Refresh, for example, Tweetie for some libraries that make it pretty straightforward.

0
source

You need to send a simple request from the application (possibly by a timer event) that will ask the server for updates. If your content on the server has been updated, you need to reload your content in the application.
You can track the time of changes on the server and the last time content was updated in the application.

0
source

All Articles