IM is making an iPhone app that displays data from a website on the table view. Basically put website data into an array and then display it on a table. Now whenever the website updates its data, then the user receives the date when the data is updated. Does anyone do this? Will you tell me some different ways?
So, are you caching the website's data on the phone and only a time Are updating once, or are you hosting the website and loading every time the app starts?
If you are not collecting it (with core data ,
user default
, NSKeyedArchiver
, etc.) How difficult would you be able to tell that the data has changed?
In that case (not stored) you can generate the hash value of the data after dragging the data from the website and with it the NSUserDefaults
a NSDate
The next time you pull information from the website, you will again generate a hash and compare it to the previous value. If they match, the content was not updated, otherwise it was and you store the new hash values and the current date.
If you have control over the website then you can do a few things.
-
When the website was last updated and compiled with the date stored locally, this will allow you to use the HEAD
HTTP definition This will allow you to check whether a complete GET
request requires you to allow network access to be reduced.
-
Good luck.
UPDATE
Then your best bet is [myArray hash]
And will store it in NSUserDefaults, e.g.
NSUntigerated hash value = [Maira Arre hash]; NSDT * now = [NSDT now]; NSUserDefaults * prefs = [NSUserDefaults standard user defaults]; [Prefetch set object: hash well to ca: @ "hash"]; [Prefs setObject: for now that: @ "date"]; // You may have to convert the date to a string. [Synchronize prefus];
and later it loads when the app starts (or becomes active):
// reload the website and hash Generate NSUInteger newHashValue = [myArray hash]; NSUserDefaults * prefs = [NSUserDefaults standard user defaults]; NSUInteger * oldHashValue = [prefix stringforki: @ "hash"]; NSDate * contentDate; If (newHashValue == old hash value) {contentDate = [prefof defaulforki: @ "date"]; } And {contentDate = [now NSDT]; // store new date // and new hash}
Comments
Post a Comment