选项卡栏应用程序中的共享托管对象上下文更新实体不会传播到其他选项卡

发布于 2024-12-11 16:47:03 字数 699 浏览 0 评论 0原文

我正在开发一个标签栏应用程序,它从 Flickr 获取地点和照片,将数据存储在 CD 中,并允许用户查看保存为收藏夹的照片。

此应用程序将托管对象上下文从应用程序委托共享到其他选项卡。 核心数据中有两个自定义实体:地点和照片。它们具有适当的一对多和反向关系设置。

第一个选项卡从 flickr 获取数据并将其存储到核心数据中:

NavigationController -> TableViewController(地点)-> TableViewController(所选地点的照片)-> ViewController(显示照片和收藏夹按钮)

第二个选项卡栏类似,但仅通过获取结果控制器使用来自核心数据的输入:

NavigationController -> TableViewController(CD 中的 Places)-> TableViewController(来自所选位置的最喜欢的照片)-> ViewController(显示照片和用于切换收藏夹状态的按钮)

我遇到的问题是这种情况: 1) 收藏第一个选项卡中的照片。 2) 在第二个选项卡中查看照片并将收藏夹切换回否。 3)返回到第一个选项卡,其中照片实体仍然是最喜欢的T_T。

我似乎无法使第二个选项卡中的更新传播到第一个选项卡。

我在设置属性后查看了 NSNotification,从托管对象上下文中调用 save,但我被难住了......救命!

I'm working on a tab bar application that fetches places and photos from Flickr, stores the data in CD and allows the user to view photos saved as favorite.

This application shares a managed object context from the app delegate to the other tabs.
There are two custom entities in Core Data: Places and Photos. These have the appropriate one to many and inverse relationships setup.

The first tab fetches data from flickr and stores it into core data:

NavigationController -> TableViewController (of Places) -> TableViewController (of photos for selected place) -> ViewController (present photo & button to favorite)

The second tab bar is similar but only uses input from core data via Fetched results controllers:

NavigationController -> TableViewController (of Places from CD) -> TableViewController (of favorite photos from selected place) -> ViewController (present photo & button to toggle favorite status)

The problem I'm having is this scenario:
1) Favorite a photo in first tab.
2) View photo in second tab and toggle favorite back to no.
3) Return to first tab where photo entity is still favorite T_T.

I can't seem to make that update in the second tab propagate through to the first one.

I've looked at NSNotification after setting the property, calling save from the managed object context, but I am stumped ... help!

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

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

发布评论

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

评论(1

べ映画 2024-12-18 16:47:03

哇我真是个傻瓜。显然没有核心数据问题...只是我检查设置按钮标题 self.photo.isFavorite 是从 CD 返回的 nsnumber 而不是 bool...

所以 if(self.photo.isfavorite) 总是返回 yes

检查是否1 现在解决了

/queue emojii

m(_ _)m ゴメンナサイ

Wow I'm a fool. Apparently there was no core data problem... just my check to set the button title self.photo.isFavorite is a nsnumber returned from CD not a bool...

so if(self.photo.isfavorite) was always returning yes

checking if 1 now solves

/queue emojii

m(_ _)m ゴメンナサイ

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