ios - Refreshing an App's JSON content once every new day in Swift -


i have app parses couple random strings using json , app reload , show new content everyday instead of looking @ old content day before. refreshing once show new days content. kinda of "quote of day" apps out there.

i have looked background fetch , wondering if overcomplicated , if possible compare date somehow , reload json session. direction appreciated.

you can use static variable or nsuserdefault if want persistent store date , compare current date :

let refreshtime = 24.0 * 60.0 * 60.0 //for refresh every 24 hours static var lastfetcheddate : nsdate? = nil  if lastfetcheddate == nil || lastfetcheddate.timeintervalsincenow * -1.0 > refreshtime{    //reload json   lastfetcheddate = nsdate() } 

Comments

Popular posts from this blog

java - pagination of xlsx file to XSSFworkbook using apache POI -

Unlimited choices in BASH case statement -

apache - How do I stop my index.php being run twice for every user -