iOS what is the standard way for saving results from restful web services into Core Data?-Collection of common programming errors
I’m doing a series of background requests to pull the user’s data from a cloud API using Restful requests. Each request returns a day of data, and I have a rate limit of 150 per hour. This means that I will be doing a lot of calls, either in series or in parallel. Regardless, the process is expected to take some time.
What is the standard practice of dealing with saving results of such requests to Core Data – do I save each object that comes in, or do I save in batches? My concern with batching is that if connection is lost, rate limit is hit, or the app crashes, I want to gracefully terminate the download and be able to resume it at a later point, from where I left off.
-
If you save in batches, you do run the risk of losing data you’ve already downloaded if the app crashes or is forcefully closed before the save. Even if this does happen, you should be able to use CoreData to identify which items you have not yet downloaded so you can gracefully resume where you left off when the app stopped.