iPhone 应用程序的本地存储 [英] Local storage for iPhone app

查看:31
本文介绍了iPhone 应用程序的本地存储的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想开发一个应用程序.该功能类似于 RSS 提要阅读器.从 Web 服务读取 XML 并将它们显示在表视图中.但是我在处理本地存储时遇到了一些问题.我不需要存储所有历史记录,因为它需要大量存储空间.但我确实想存储几十条最新的记录,这样即使在加载新数据或没有网络连接时,用户也能真正看到一些东西.我该怎么办?我应该使用 Coredata 还是其他方法?

I want to develop an application. The functionality is similar to RSS feed reader. Read a XML from web service and display them in a table view. But I have some problems to deal with the local storage. I do not need to store all the history records since it takes a lot of storage. But I do want to store dozens of newest records so the user can really see something even when the new data is loading or there is no network connection. What should I do? Should I use Coredata or other methods?

推荐答案

有几种方法可以在你的 iOS 项目中实现这种存储(我将在这里提到的 3 种):

There are several ways to implement this storage within your iOS project (3 that I will mention here):

  1. Core Data - Core Data 非常强大,它当然可以处理您的用例.设置数据模型有一些开销.您可以在此处阅读有关核心数据的信息:https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/CoreData/index.html

SQLite 数据库 - 您的核心数据实现可能会使用 SQLite 作为其持久存储.但是,您也可以直接使用 SQLite.这允许您以任何方式处理数据,但它也需要大量开销才能以上述方式启动和运行.这可能是一个很好的解决方案,但我认为它不适合您的项目.http://www.techotopia.com/index.php/An_Example_SQLite_based_iOS_4_iPhone_Application

SQLite Database - Your core data implementation would probably use SQLite as its persistent store. However, you also can use SQLite directly. This allows you to handle the data however you want, but it also requires a lot of overhead to get it up and running in the manner you mentioned above. This can be a good solution but, I don't think it is a good fit for your project. http://www.techotopia.com/index.php/An_Example_SQLite_based_iOS_4_iPhone_Application

属性列表 - 属性列表很容易在项目中实现,用于读取和写入数据.您可以在此处阅读有关属性列表的更多信息:https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/PropertyLists/Introduction/Introduction.html

Property List - Property lists are very easy to implement within a project for both reading and writing data. You can read more about property lists here: https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/PropertyLists/Introduction/Introduction.html

希望有所帮助.

这篇关于iPhone 应用程序的本地存储的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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