iOS - how to handle online/offline data

|▌冷眼眸甩不掉的悲伤 提交于 2020-01-03 20:55:10

问题


I am currently developing an app with a big database. Think of the app as similar to TripAdvisor in the following way: multiple cities with different databases, each between 5, 10, 20, 30 MBs. My whole app is based on this data: every view needs some part of it.

I'm having big trouble finding the correct way to handle this huge chunk of data. I am currently using CoreData: I think it is a great tool, and for offline mode, it definitely works great. The problem is, I can't really combine it with "online" mode. If the user doesn't want to store the data for X/Y reason, I'm not sure how I should handle the data. Simply allocate it in variables that will be released anyway, or is there a better way to handle the data? Right now I am stocking it into CoreData without saving it: I know this is absolutely not a good way to manage it. How could I achieve this? What is the best way to handle online data and then simply stock it if the user wants it offline too?


回答1:


Option 1:

Data is always static/ not change data frequently: You should have data on online. You can fetch data by webservice and store it to local database(i.e core -data). For example: Bible, Quran app.

Option 2:

Data change frequently and user need to update frequently:same as above. Additionally, from server you send notification(i,e push-notification) to app that server has a new data.After getting notification in app, download and save data to you database.



来源:https://stackoverflow.com/questions/33106673/ios-how-to-handle-online-offline-data

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!