Search code examples
iosdata-storage

iOS Data Storage and Easy Updating


So there are a lot of questions on here about saving data but I didn't find the answer to this question.

I would like to create an app which relies on a data that is likely to change weekly or bi-weekly. I would like to store the data on the device so that if the user doesn't have access to the internet they are still able to use the app. However, when they do have access to the internet I would like for the device, on launch, to connect to a database and compare the stored values to the values on the database. If they are different I would like the local data to be updated. In this way I don't have to keep releasing update every couple weeks for simple number changes.

I am new to IOS development and don't know what the best way to approach this is. Are certain methods of storing data more easily updated in this way than others? And help/discussion on this idea would be appreciated. Thank you!


Solution

  • I would say the is the wrong approach to decide how to store your inormation. It depends on your data and what you plan to do with the data at runtime.
    Of course it is easier to overwrite a file as parsing and storing your data in coredata, but at some point you will need to process your data anyway ...

    If your data is Json or XML and you need to access it more than once, coredata is probably a good choice.

    If its a picture or binary data or you need to access it only once, a file might be the right choice - see the documentation where to put it best.

    If it is just some user related data NSUserDefaults works fine.

    If it is sensitive data or should stay on the device even after deletion of the app, the keychain is the place to choose.