I want to check a file on the server only once each day (NSURL). And, no matter if I fetch the file or not, I do not run the function (to check for the file) again that day.
This would SEEM easy... but I forsee issues. Say I had created a directory under the mainBundle: "/Library/runOnceEachDay/". Perhaps I could write to /Library/runOnceEachDay/20100601 knowing that file would only exist if I already ran the function. If it does not exist, run the function and after the function is successful write a zero length file with the date as the filename. Then check before running that function for "mainBundle/Library/runOnceEachDay/YYYYMMDD" whereas YYYYMMDD is today's date. If that file exists, do not run.
I could run a housecleaning routine to clean that directory once/week or something. Any better ideas?
Thanks!
When you start the app, get the previous phone home date/time (NSDate) from NSUserDefaults. (It won't be there the first time). This SO question (option 1) demonstrates how.
If more than 24 hours (or 7 days or whatever) has elapsed since that previous date/time (or you didn't find it there) then phone home and save the current date/time in NSUserDefaults for next startup.