iOS-如何处理在线/离线数据 [英] iOS - how to handle online/offline data

查看:75
本文介绍了iOS-如何处理在线/离线数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在开发具有大型数据库的应用程序。可以通过以下方式将应用程序视为类似于TripAdvisor的应用程序:多个具有不同数据库的城市,每个数据库之间有5、10、20、30 MB。我的整个应用程序都基于这些数据:每个视图都需要其中的一部分。

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.

我很难找到正确的方法来处理大量数据。我目前正在使用CoreData:我认为这是一个很棒的工具,对于离线模式,它肯定很棒。
问题是,我无法真正将其与在线模式结合使用。如果用户出于X / Y原因不想存储数据,则不确定如何处理数据。
只是将其分配到将要释放的变量中,还是有更好的方法来处理数据?
现在我将其存储到CoreData中而不保存它:我知道这绝对不是管理它的好方法。我怎样才能做到这一点?
处理用户在线数据,然后如果用户也希望离线存储数据的最佳方法是什么?

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:

数据始终是静态的/不经常更改数据:
您应该在线上拥有数据。您可以通过 webservice 获取数据并将其存储到本地数据库(即core -data)。例如:圣经,古兰经应用。

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.

选项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.

这篇关于iOS-如何处理在线/离线数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆