I'm developing an application for the iPhone which gets all data from a database from a web service. I receive the information in JSON format and make constant calls to the web service for data. My question is should I be using core data? Right now I just make a request to the web service use the information I need and make calls to data when needed. But should I put the data into core data because I cannot figure if it would help or even make sense to do. Since there are thousands of rows of data on the server I can't imagine constantly saving information into core data in effect copying the database from the server onto the phone. That does not seem to make sense or be a good idea performance wise. Wouldn't I eventually run out of room in the core data database or use up too much room on the device? Maybe I'm not fully grasping the concept.
我正在为iPhone开发一个应用程序,它从Web服务获取数据库中的所有数据。我收到JSON格式的信息,并不断调用Web服务来获取数据。我的问题是我应该使用核心数据吗?现在我只是向Web服务请求使用我需要的信息,并在需要时调用数据。但是我应该将数据放入核心数据中,因为我无法确定它是否有帮助甚至是有意义的。由于服务器上有数千行数据,我无法想象不断将信息保存到核心数据中,实际上将数据库从服务器复制到手机上。这似乎没有意义,也不是表现明智的好主意。我不会最终耗尽核心数据库中的空间或在设备上占用太多空间吗?也许我没有完全理解这个概念。
7 个解决方案
#1
5
In my opinion there is no use of Core data as per your requirement. As you are asking your web service, every time you need new data. Your App is a web App, not a native one. Better work on how to speed up communication by using efficient data objects (you are already using JSON, thats good.). No need of CoreData according to me. Here are the links supporting my point:
在我看来,根据您的要求,没有使用核心数据。当您询问Web服务时,每次需要新数据时。您的应用程序是Web应用程序,而不是本机应用程序。如何通过使用高效的数据对象加快沟通速度(您已经在使用JSON,这很好。)。根据我不需要CoreData。以下是支持我观点的链接:
Why Core Data
Core data features overview
为什么核心数据核心数据功能概述
#2
2
Of all of the ways to persist data on the iPhone, Core Data is the best one to use for non-trivial data storage. It can reduce the memory overhead of your app, increase responsiveness, and save you from writing a lot of boilerplate code. According to Tutorial of RayWenderlich and Tutorial of Objc.io, you can get a good start. And personally, using Apple's class is better for version control for your iOS Apps.
在将数据保存在iPhone上的所有方法中,Core Data是用于非平凡数据存储的最佳方法。它可以减少应用程序的内存开销,提高响应速度,并使您免于编写大量样板代码。根据RayWenderlich教程和Objc.io教程,你可以有一个良好的开端。个人而言,使用Apple的类更适合iOS应用程序的版本控制。
#3
0
@Marlow Charite storing data in local is based on requirement.
@Marlow Charite在本地存储数据是基于要求的。
If you are having requirements like updated data must be loaded everytime for ex:NewsChannel. In this requirement latest data must be fetched everytime whenever user launches application,here there is no need of offline data storage.
如果您有更新数据的要求必须每次都加载ex:NewsChannel。在此要求中,每当用户启动应用程序时,必须每次都获取最新数据,这里不需要离线数据存储。
If you are having requirements like updated data must be loaded as and when needed for ex:Social Network. In this requirement feeds loaded once then you can store in local db and load from local whenever user launches application.Implement pull to refresh for user to load more data.
如果您有更新数据的要求必须在ex:Social Network需要时加载。在此需求中加载一次,然后您可以存储在本地数据库中,并在用户启动应用程序时从本地加载。实现拉动以刷新用户以加载更多数据。
Choosing sqlite db or core data storage for offline storage. This link will help you.
为离线存储选择sqlite db或核心数据存储。此链接将帮助您。
#4
0
I think use Core data is no problem, sqlite can help you save or cache request data, just a light sqlite, include sqite3 or FMDB(Third-party libraries), not affect performance.
我认为使用Core数据没问题,sqlite可以帮你保存或缓存请求数据,只需轻量级sqlite,包括sqite3或FMDB(第三方库),不影响性能。
#5
0
Seems like there's no need to use core data at all since you're constantly fetching info from the web and you don't need the data to persist between app launches.
似乎根本不需要使用核心数据,因为您不断从Web获取信息,并且您不需要在应用程序启动之间保持数据。
#6
-1
Yes you can use the core data but there is some limitation using core data like the query you search for it.
是的,您可以使用核心数据,但使用核心数据(例如您搜索的查询)存在一些限制。
Otherwise you can use the sqlite database there will be no any limitation using this and you can search for any record with sqlite..
否则你可以使用sqlite数据库使用它没有任何限制,你可以用sqlite搜索任何记录..
Hope it will be helpful.
希望它会有所帮助。
#7
-1
As a few other posters have said, if you are constantly fetching the data from the web, then there is no need to put in persistent storage. Writing back and forth between RAM and flash is a big performance hit.
正如其他一些海报所说,如果你不断从网上获取数据,那么就没有必要放入持久存储。在RAM和闪存之间来回写入是一个很大的性能影响。
If you do need persistent storage, and are developing exclusively for the iOS platform, then Core Data is a good way to go as it is fairly high level and integrates well with iCloud and other Apple services. Otherwise, if you are considering Android and Windows as well, I suggest going with sqlite or FMDB as sqlite's wrapper. Here is another thread I found:
如果您确实需要持久存储,并且专门为iOS平台开发,那么Core Data是一个很好的方式,因为它相当高水平并且与iCloud和其他Apple服务很好地集成。否则,如果您正在考虑Android和Windows,我建议使用sqlite或FMDB作为sqlite的包装器。这是我发现的另一个主题:
Core Data VS Sqlite or FMDB....?
核心数据VS Sqlite或FMDB ....?
Hope this helps.
希望这可以帮助。
#1
5
In my opinion there is no use of Core data as per your requirement. As you are asking your web service, every time you need new data. Your App is a web App, not a native one. Better work on how to speed up communication by using efficient data objects (you are already using JSON, thats good.). No need of CoreData according to me. Here are the links supporting my point:
在我看来,根据您的要求,没有使用核心数据。当您询问Web服务时,每次需要新数据时。您的应用程序是Web应用程序,而不是本机应用程序。如何通过使用高效的数据对象加快沟通速度(您已经在使用JSON,这很好。)。根据我不需要CoreData。以下是支持我观点的链接:
Why Core Data
Core data features overview
为什么核心数据核心数据功能概述
#2
2
Of all of the ways to persist data on the iPhone, Core Data is the best one to use for non-trivial data storage. It can reduce the memory overhead of your app, increase responsiveness, and save you from writing a lot of boilerplate code. According to Tutorial of RayWenderlich and Tutorial of Objc.io, you can get a good start. And personally, using Apple's class is better for version control for your iOS Apps.
在将数据保存在iPhone上的所有方法中,Core Data是用于非平凡数据存储的最佳方法。它可以减少应用程序的内存开销,提高响应速度,并使您免于编写大量样板代码。根据RayWenderlich教程和Objc.io教程,你可以有一个良好的开端。个人而言,使用Apple的类更适合iOS应用程序的版本控制。
#3
0
@Marlow Charite storing data in local is based on requirement.
@Marlow Charite在本地存储数据是基于要求的。
If you are having requirements like updated data must be loaded everytime for ex:NewsChannel. In this requirement latest data must be fetched everytime whenever user launches application,here there is no need of offline data storage.
如果您有更新数据的要求必须每次都加载ex:NewsChannel。在此要求中,每当用户启动应用程序时,必须每次都获取最新数据,这里不需要离线数据存储。
If you are having requirements like updated data must be loaded as and when needed for ex:Social Network. In this requirement feeds loaded once then you can store in local db and load from local whenever user launches application.Implement pull to refresh for user to load more data.
如果您有更新数据的要求必须在ex:Social Network需要时加载。在此需求中加载一次,然后您可以存储在本地数据库中,并在用户启动应用程序时从本地加载。实现拉动以刷新用户以加载更多数据。
Choosing sqlite db or core data storage for offline storage. This link will help you.
为离线存储选择sqlite db或核心数据存储。此链接将帮助您。
#4
0
I think use Core data is no problem, sqlite can help you save or cache request data, just a light sqlite, include sqite3 or FMDB(Third-party libraries), not affect performance.
我认为使用Core数据没问题,sqlite可以帮你保存或缓存请求数据,只需轻量级sqlite,包括sqite3或FMDB(第三方库),不影响性能。
#5
0
Seems like there's no need to use core data at all since you're constantly fetching info from the web and you don't need the data to persist between app launches.
似乎根本不需要使用核心数据,因为您不断从Web获取信息,并且您不需要在应用程序启动之间保持数据。
#6
-1
Yes you can use the core data but there is some limitation using core data like the query you search for it.
是的,您可以使用核心数据,但使用核心数据(例如您搜索的查询)存在一些限制。
Otherwise you can use the sqlite database there will be no any limitation using this and you can search for any record with sqlite..
否则你可以使用sqlite数据库使用它没有任何限制,你可以用sqlite搜索任何记录..
Hope it will be helpful.
希望它会有所帮助。
#7
-1
As a few other posters have said, if you are constantly fetching the data from the web, then there is no need to put in persistent storage. Writing back and forth between RAM and flash is a big performance hit.
正如其他一些海报所说,如果你不断从网上获取数据,那么就没有必要放入持久存储。在RAM和闪存之间来回写入是一个很大的性能影响。
If you do need persistent storage, and are developing exclusively for the iOS platform, then Core Data is a good way to go as it is fairly high level and integrates well with iCloud and other Apple services. Otherwise, if you are considering Android and Windows as well, I suggest going with sqlite or FMDB as sqlite's wrapper. Here is another thread I found:
如果您确实需要持久存储,并且专门为iOS平台开发,那么Core Data是一个很好的方式,因为它相当高水平并且与iCloud和其他Apple服务很好地集成。否则,如果您正在考虑Android和Windows,我建议使用sqlite或FMDB作为sqlite的包装器。这是我发现的另一个主题:
Core Data VS Sqlite or FMDB....?
核心数据VS Sqlite或FMDB ....?
Hope this helps.
希望这可以帮助。