Reputation: 680
I have a large database containing products. I was thinking of fetching all products from the database when the iOS app launches and then save and restructure the data with CoreData, are you following?
However, the products in the database and especially the prices could change between different days. Hence, I think I need to preload the data every time I open the app. This will take a while, especially with slow Internet. I am wondering if there is a better solution?
Thanks, Casper
Upvotes: 0
Views: 184
Reputation: 3791
Think about what data will change and what data will not...
Consider breaking up your data into groups - those that change regularly, those that change infrequently and those that never change.
Then you’ll be able to upload the data for your app based on group.
What data may be uploaded once:
What data may be uploaded daily:
What data may be uploaded infrequently:
Perhaps there will be new products uploaded also?
I recommend that you consider use of thumbnail images and full size images.
As a guide, thumbnail images should be of small dimension and file size... maybe 300 x 300 pixels and less than 150kb. Thumbnail images can be saved as a Data
type using Core Data (which is persisted as a blob in SQLite).
Full sized (large file size) images can be persisted using Core Data, however there are different ways to achieve this.
There is much written, both on SO and other sites, regarding storage of large file size images using Core Data.
My preference is to save the image file to a custom app directory/ folder in your app sandbox that is not backed up my iTunes or iCloud and save a reference to that image file (as a file path) as a String
attribute in your Core Data model. In this way you’re able to persist the image files locally and only upload the changes, when necessary.
So by using different groups of data, you can also spilt up the upload into chunks... those that are needed:
Upvotes: 1