iOS:缓存下载的 RSS 消息的最佳方式

发布于 2024-09-30 05:12:46 字数 302 浏览 0 评论 0原文

我正在为 iPhone 实现 RSS 阅读器的基本功能。我下载了一堆短信并将它们显示在列表中给用户。每条消息都封装在一个 MyMessage 对象中,其中包含标题、正文、url 等。

我希望确保缓存 20 条最新消息。最好的方法是什么?我应该使用带密钥的存档,并且只让 MyMessage 类实现 NSCoding 协议吗?如果我选择这种方法,我可以将新消息附加到包含存档的文件中(同样,当消息计数超过 20 时,我可以删除旧消息吗)?

本质上我的问题是:使用密钥存档是正确的方法吗?如果是这样,我如何根据需要从存档中追加/删除消息?

谢谢!

I'm implementing what essential amounts to an RSS reader for iPhone. I download a bunch of short messages and display them to the user in a list. Each message is encapsulated in a MyMessage object that contains the title, the body, url, etc.

I want to be sure to cache the 20 most recent messages. What is the best way to do this? Should I use a keyed archive, and just have the MyMessage class implement the NSCoding protocol. If I choose this approach, can I append new message to the file containing the archive (and similarly, can I delete old messages when the message count exceeds 20)?

Essentially my question is: is using a keyed archive the right approach? And if so, how can I append/delete messages from the archive as necessary?

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

眼中杀气 2024-10-07 05:12:46

为什么不使用 CoreData?使其与要缓存的简单对象一起使用是相当简单的。

Why not use CoreData? Its fairly trivial to make that work with your simple object to cache.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文