Ok the title seems generic so let me explain. I have a note-taking application that is not only saved in the database, but also sent to the server through JSON where a website will parse the data and display it. The problem is this: what if the user has no internet connection at the time he/she created the note?
This is how it works: The user will press the save button and it will save the data into the database as well as send the JSON string to the server. If there is no internet connection, the user can still save the data into the database. But how about the JSON string? How will the website know if updates where made when there is no internet connection at that time? Any suggestions will be very much appreciated.
A basic solution would be to store in your database whether the data had been saved to the server successfully or whether the record is “unsynced”. If a save results in an error due to a lack of connectivity you can then make a call after a set time that will check again if there are any “unsynced” records, and try and save those. If it fails again, reschedule the check.
You can use something like
NSObjectperformSelector:withObject:afterDelay:in order to run some code after a period of time.You’ll also probably want to perform this check when the app starts up or returns from the background, to catch any unsycned records if the app was not running in between.