iPhone核心数据更新记录

发布于 2024-09-08 10:27:01 字数 250 浏览 0 评论 0原文

我正在尝试找到一个解决方案来解决我认为很简单的问题。我正在使用 coredata 来维护我的应用程序中的书签列表。仅存储三个字段:出价、订单和标题。

在某些情况下我想更新现有记录。目前我正在使用谓词来搜索特定的出价。我遇到的问题是将记录作为对象访问,以便可以更新和重新保存。

有什么帮助吗?另外,对于 plist 或用户默认值中应存储多少数据,是否有任何指导原则?

一个用户可能有数百个书签。

谢谢,

豪伊

I'm trying to find a solution to what I think has to be a simple problem. I'm using coredata to maintain a list of bookmarks in my app. there are only three fields being stored, bid, order and title.

in some cases I want to update an existing record. currently I'm using a predicate to search for a particular bid. the problem I'm having is accessing the record as an object so it can be updated and resaved.

any help? also, are there any guidelines for how much data should be stored in a plist or user default?

a user can potentially have hundreds of bookmarks.

thanks,

howie

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

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

发布评论

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

评论(2

随遇而安 2024-09-15 10:27:01

获取的结果作为一组返回。如果只有一个结果,您可以调用集合上的anyObject 来获取实际的托管对象。如果您需要一些详细的帮助,请发布一些代码。

Core Data 是这里正确的解决方案,因此不要诉诸 plist 或用户默认值。

Fetched results come back as a set. If there is only a single result, you could call anyObject on the set to obtain the actual managed object. Post some code if you want some detailed help.

Core Data is the right solution here, so don't resort to plists or user defaults.

寒尘 2024-09-15 10:27:01

获取的结果作为 NSSet 的实例返回。获取您想要更改的对象(使用 anyObject 或 objectAtIndex: 或者您可以循环遍历整个集合),然后更改您想要的属性。然后只需在 ManagedObjectContext 上调用函数“save:”即可。

The fetched results are returned as an instance of NSSet. Get the object you want to change (either with anyObject or objectAtIndex: or you can loop through the whole set) and then change the property you want. Then just call the function "save:" on your managedObjectContext.

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