取消分配的视图控制器导致EXC_BAD_ACCESS,因为读取结果控制器更新 [英] Deallocated view controller causing EXC_BAD_ACCESS because of fetched results controller update

查看:103
本文介绍了取消分配的视图控制器导致EXC_BAD_ACCESS,因为读取结果控制器更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个导航应用程序,在堆栈上有3个视图控制器。导航根推送AvailableItemsViewController,将受管对象上下文传递给它。

I have a navigation app with 3 view controllers on the stack. The navigation root pushes AvailableItemsViewController, passing a managed object context to it.

此视图是一个使用提取结果控制器来填充它的表视图,它有一个添加按钮,推送另一个控制器(CreateNewItemViewController)

This view, which is a table view that uses a fetched results controller to populate it, has an add button which pushes another controller (CreateNewItemViewController) I pass that context off to it.

在CreateNewItemViewController中,我创建一个托管对象,将其保存到上下文,然后弹出视图控制器。

In CreateNewItemViewController I create a managed object, save it to the context, then pop the view controller.

我可以来回保存项目到AvailableItemsViewController,直到我回到导航根。 (AvailableItemsViewController获取释放)。

I can go back and forth saving items to the AvailableItemsViewController until I go back to the navigation root. (The AvailableItemsViewController gets deallocated).

之后,如果我回到第三个控制器并尝试保存,我会得到:

After this if I drill back down to the third controller and try to save I get this:

我的错误(zombies enabled:)

Here's my error (zombies enabled:)


- [AvailableItemsViewController controllerWillChangeContent:]:消息发送到释放的实例0x1f6500

-[AvailableItemsViewController controllerWillChangeContent:]: message sent to deallocated instance 0x1f6500

且不含僵尸


- [__ NSArrayM controllerWillChangeContent:]:无法识别的选择器到实例0x4ecdee0

-[__NSArrayM controllerWillChangeContent:]: unrecognized selector sent to instance 0x4ecdee0

(我已经得到了很多不同的随机输出,似乎控制器的目的地WillChangeContent:message是随机的)

(i've gotten a lot of different random output on this, it seems that the destination of the controllerWillChangeContent: message is random)

所有控制器都将其属性设置为nil,并分别在viewDidUnload和dealloc中释放ivar。

all controllers are setting their properties to nil and releasing ivars in viewDidUnload and dealloc respectively.

当第三个控制器(CreateNewItemViewController)中的[self.managedObjectContext save:& error]步进时发生崩溃

When stepping through the crash happens at [self.managedObjectContext save:&error] in the third controller (CreateNewItemViewController)

推荐答案

如上所述,请确保您的FRC不泄漏。但是,如果问题仍然存在,请在控制器的dealoc中将FRC委托设置为nil。这将禁用更改跟踪,并防止调用您的释放VC。

As mentioned above, make sure your FRC is not leaking. However, if the problem persists, set the FRC delegate to nil in your controller's dealoc. This will disable change tracking and prevent calls to your deallocated VC.

这篇关于取消分配的视图控制器导致EXC_BAD_ACCESS,因为读取结果控制器更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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