Ipad [controllerWillChangeContent:]:发送到解除分配实例的消息
我的ipad应用程序有问题 我有一个视图,它有两种访问方式,如果我用一种方式访问它,它工作得非常好。但是,如果我通过另一个导入,则在保存上下文时会崩溃 我怀疑这是在家长(客户订单)中——我收到了一个带有以下信息的僵尸: [OrdersByCustomer controllerWillChangeContent:]:发送到解除分配实例0x101020的消息 当我用僵尸工具运行它时,我得到:Ipad [controllerWillChangeContent:]:发送到解除分配实例的消息,ipad,memory-management,xcode4,nsfetchedresultscontroller,nsmanagedobjectcontext,Ipad,Memory Management,Xcode4,Nsfetchedresultscontroller,Nsmanagedobjectcontext,我的ipad应用程序有问题 我有一个视图,它有两种访问方式,如果我用一种方式访问它,它工作得非常好。但是,如果我通过另一个导入,则在保存上下文时会崩溃 我怀疑这是在家长(客户订单)中——我收到了一个带有以下信息的僵尸: [OrdersByCustomer controllerWillChangeContent:]:发送到解除分配实例0x101020的消息 当我用僵尸工具运行它时,我得到: # Category Event Type RefCt Timestamp Addres
# Category Event Type RefCt Timestamp Address Size Responsible Library Responsible Caller
0 OrdersByCustomer Malloc 1 00:35.545.273 0x89cafc0 272 Dentanet -[CustomersRootController tableView:didSelectRowAtIndexPath:]
1 OrdersByCustomer Retain 2 00:35.545.357 0x89cafc0 0 Dentanet -[CustomersRootController tableView:didSelectRowAtIndexPath:]
2 OrdersByCustomer Retain 3 00:35.545.414 0x89cafc0 0 UIKit -[UISplitViewController setViewControllers:]
3 OrdersByCustomer Release 2 00:35.545.434 0x89cafc0 0 UIKit -[UISplitViewController setViewControllers:]
4 OrdersByCustomer Retain 3 00:35.546.380 0x89cafc0 0 UIKit -[UINib instantiateWithOwner:options:]
5 OrdersByCustomer Retain 4 00:35.546.406 0x89cafc0 0 UIKit -[UINib instantiateWithOwner:options:]
6 OrdersByCustomer Retain 5 00:35.546.631 0x89cafc0 0 UIKit -[UIProxyObject initWithCoder:]
7 OrdersByCustomer Retain 6 00:35.546.636 0x89cafc0 0 UIKit -[UIRuntimeConnection initWithCoder:]
8 OrdersByCustomer Retain 7 00:35.546.665 0x89cafc0 0 Foundation -[NSKeyedUnarchiver _replaceObject:withObject:]
9 OrdersByCustomer Release 6 00:35.546.669 0x89cafc0 0 UIKit -[UIRuntimeConnection initWithCoder:]
10 OrdersByCustomer Retain 7 00:35.546.671 0x89cafc0 0 UIKit -[UIRuntimeConnection initWithCoder:]
11 OrdersByCustomer Autorelease 00:35.546.682 0x89cafc0 0 UIKit -[UIRuntimeConnection initWithCoder:]
12 OrdersByCustomer Retain 8 00:35.546.687 0x89cafc0 0 UIKit -[UIRuntimeConnection initWithCoder:]
13 OrdersByCustomer Retain 9 00:35.548.308 0x89cafc0 0 UIKit -[UIRuntimeConnection initWithCoder:]
14 OrdersByCustomer Autorelease 00:35.548.310 0x89cafc0 0 UIKit -[UIRuntimeConnection initWithCoder:]
15 OrdersByCustomer Retain 10 00:35.548.313 0x89cafc0 0 UIKit -[UIRuntimeConnection initWithCoder:]
16 OrdersByCustomer Retain 11 00:35.548.363 0x89cafc0 0 UIKit -[UIRuntimeConnection initWithCoder:]
17 OrdersByCustomer Autorelease 00:35.548.365 0x89cafc0 0 UIKit -[UIRuntimeConnection initWithCoder:]
18 OrdersByCustomer Retain 12 00:35.548.367 0x89cafc0 0 UIKit -[UIRuntimeConnection initWithCoder:]
19 OrdersByCustomer Retain 13 00:35.552.662 0x89cafc0 0 UIKit -[UIRuntimeConnection initWithCoder:]
20 OrdersByCustomer Autorelease 00:35.552.665 0x89cafc0 0 UIKit -[UIRuntimeConnection initWithCoder:]
21 OrdersByCustomer Retain 14 00:35.552.667 0x89cafc0 0 UIKit -[UIRuntimeConnection initWithCoder:]
22 OrdersByCustomer Retain 15 00:35.554.265 0x89cafc0 0 UIKit -[UIRuntimeConnection initWithCoder:]
23 OrdersByCustomer Autorelease 00:35.554.267 0x89cafc0 0 UIKit -[UIRuntimeConnection initWithCoder:]
24 OrdersByCustomer Retain 16 00:35.554.270 0x89cafc0 0 UIKit -[UIRuntimeConnection initWithCoder:]
25 OrdersByCustomer Retain 17 00:35.555.888 0x89cafc0 0 UIKit -[UIRuntimeConnection initWithCoder:]
26 OrdersByCustomer Autorelease 00:35.555.891 0x89cafc0 0 UIKit -[UIRuntimeConnection initWithCoder:]
27 OrdersByCustomer Retain 18 00:35.555.893 0x89cafc0 0 UIKit -[UIRuntimeConnection initWithCoder:]
28 OrdersByCustomer Retain 19 00:35.557.078 0x89cafc0 0 UIKit -[UIRuntimeConnection initWithCoder:]
29 OrdersByCustomer Autorelease 00:35.557.081 0x89cafc0 0 UIKit -[UIRuntimeConnection initWithCoder:]
30 OrdersByCustomer Retain 20 00:35.557.083 0x89cafc0 0 UIKit -[UIRuntimeConnection initWithCoder:]
31 OrdersByCustomer Retain 21 00:35.558.379 0x89cafc0 0 UIKit -[UIRuntimeConnection initWithCoder:]
32 OrdersByCustomer Autorelease 00:35.558.382 0x89cafc0 0 UIKit -[UIRuntimeConnection initWithCoder:]
33 OrdersByCustomer Retain 22 00:35.558.384 0x89cafc0 0 UIKit -[UIRuntimeConnection initWithCoder:]
34 OrdersByCustomer Retain 23 00:35.558.428 0x89cafc0 0 UIKit -[UIRuntimeConnection initWithCoder:]
35 OrdersByCustomer Autorelease 00:35.558.430 0x89cafc0 0 UIKit -[UIRuntimeConnection initWithCoder:]
36 OrdersByCustomer Retain 24 00:35.558.434 0x89cafc0 0 UIKit -[UIRuntimeConnection initWithCoder:]
37 OrdersByCustomer Retain 25 00:35.559.611 0x89cafc0 0 UIKit -[UIRuntimeConnection initWithCoder:]
38 OrdersByCustomer Autorelease 00:35.559.614 0x89cafc0 0 UIKit -[UIRuntimeConnection initWithCoder:]
39 OrdersByCustomer Retain 26 00:35.559.617 0x89cafc0 0 UIKit -[UIRuntimeConnection initWithCoder:]
40 OrdersByCustomer Retain 27 00:35.561.021 0x89cafc0 0 UIKit -[UIRuntimeConnection initWithCoder:]
41 OrdersByCustomer Autorelease 00:35.561.024 0x89cafc0 0 UIKit -[UIRuntimeConnection initWithCoder:]
42 OrdersByCustomer Retain 28 00:35.561.026 0x89cafc0 0 UIKit -[UIRuntimeConnection initWithCoder:]
43 OrdersByCustomer Retain 29 00:35.574.693 0x89cafc0 0 UIKit -[UIRuntimeConnection initWithCoder:]
44 OrdersByCustomer Autorelease 00:35.574.695 0x89cafc0 0 UIKit -[UIRuntimeConnection initWithCoder:]
45 OrdersByCustomer Retain 30 00:35.574.699 0x89cafc0 0 UIKit -[UIRuntimeConnection initWithCoder:]
46 OrdersByCustomer Retain 31 00:35.576.664 0x89cafc0 0 UIKit -[UIRuntimeConnection initWithCoder:]
47 OrdersByCustomer Autorelease 00:35.576.665 0x89cafc0 0 UIKit -[UIRuntimeConnection initWithCoder:]
48 OrdersByCustomer Retain 32 00:35.576.667 0x89cafc0 0 UIKit -[UIRuntimeConnection initWithCoder:]
49 OrdersByCustomer Retain 33 00:35.578.215 0x89cafc0 0 UIKit -[UIRuntimeConnection initWithCoder:]
50 OrdersByCustomer Autorelease 00:35.578.217 0x89cafc0 0 UIKit -[UIRuntimeConnection initWithCoder:]
51 OrdersByCustomer Retain 34 00:35.578.220 0x89cafc0 0 UIKit -[UIRuntimeConnection initWithCoder:]
52 OrdersByCustomer Retain 35 00:35.579.428 0x89cafc0 0 UIKit -[UIRuntimeConnection initWithCoder:]
53 OrdersByCustomer Autorelease 00:35.579.430 0x89cafc0 0 UIKit -[UIRuntimeConnection initWithCoder:]
54 OrdersByCustomer Retain 36 00:35.579.433 0x89cafc0 0 UIKit -[UIRuntimeConnection initWithCoder:]
55 OrdersByCustomer Retain 37 00:35.580.833 0x89cafc0 0 UIKit -[UIRuntimeConnection initWithCoder:]
56 OrdersByCustomer Autorelease 00:35.580.835 0x89cafc0 0 UIKit -[UIRuntimeConnection initWithCoder:]
57 OrdersByCustomer Retain 38 00:35.580.837 0x89cafc0 0 UIKit -[UIRuntimeConnection initWithCoder:]
58 OrdersByCustomer Retain 39 00:35.582.224 0x89cafc0 0 UIKit -[UIRuntimeConnection initWithCoder:]
59 OrdersByCustomer Autorelease 00:35.582.226 0x89cafc0 0 UIKit -[UIRuntimeConnection initWithCoder:]
60 OrdersByCustomer Retain 40 00:35.582.229 0x89cafc0 0 UIKit -[UIRuntimeConnection initWithCoder:]
61 OrdersByCustomer Retain 41 00:35.583.419 0x89cafc0 0 UIKit -[UIRuntimeConnection initWithCoder:]
62 OrdersByCustomer Autorelease 00:35.583.421 0x89cafc0 0 UIKit -[UIRuntimeConnection initWithCoder:]
63 OrdersByCustomer Retain 42 00:35.583.424 0x89cafc0 0 UIKit -[UIRuntimeConnection initWithCoder:]
64 OrdersByCustomer Retain 43 00:35.584.848 0x89cafc0 0 UIKit -[UIRuntimeConnection initWithCoder:]
65 OrdersByCustomer Autorelease 00:35.584.850 0x89cafc0 0 UIKit -[UIRuntimeConnection initWithCoder:]
66 OrdersByCustomer Retain 44 00:35.584.853 0x89cafc0 0 UIKit -[UIRuntimeConnection initWithCoder:]
67 OrdersByCustomer Retain 45 00:35.584.895 0x89cafc0 0 UIKit -[UIRuntimeConnection initWithCoder:]
68 OrdersByCustomer Autorelease 00:35.584.898 0x89cafc0 0 UIKit -[UIRuntimeConnection initWithCoder:]
69 OrdersByCustomer Retain 46 00:35.584.900 0x89cafc0 0 UIKit -[UIRuntimeConnection initWithCoder:]
70 OrdersByCustomer Retain 47 00:35.584.952 0x89cafc0 0 UIKit -[UIRuntimeConnection initWithCoder:]
71 OrdersByCustomer Autorelease 00:35.584.954 0x89cafc0 0 UIKit -[UIRuntimeConnection initWithCoder:]
72 OrdersByCustomer Retain 48 00:35.584.957 0x89cafc0 0 UIKit -[UIRuntimeConnection initWithCoder:]
73 OrdersByCustomer Retain 49 00:35.587.241 0x89cafc0 0 UIKit -[UIRuntimeConnection initWithCoder:]
74 OrdersByCustomer Autorelease 00:35.587.244 0x89cafc0 0 UIKit -[UIRuntimeConnection initWithCoder:]
75 OrdersByCustomer Retain 50 00:35.587.246 0x89cafc0 0 UIKit -[UIRuntimeConnection initWithCoder:]
76 OrdersByCustomer Retain 51 00:35.587.288 0x89cafc0 0 UIKit -[UIRuntimeConnection initWithCoder:]
77 OrdersByCustomer Autorelease 00:35.587.291 0x89cafc0 0 UIKit -[UIRuntimeConnection initWithCoder:]
78 OrdersByCustomer Retain 52 00:35.587.293 0x89cafc0 0 UIKit -[UIRuntimeConnection initWithCoder:]
79 OrdersByCustomer Release 51 00:35.598.083 0x89cafc0 0 UIKit -[UINib instantiateWithOwner:options:]
80 OrdersByCustomer Release 50 00:35.598.087 0x89cafc0 0 UIKit -[UINib instantiateWithOwner:options:]
81 OrdersByCustomer Release 49 00:35.598.098 0x89cafc0 0 UIKit -[UINib instantiateWithOwner:options:]
82 OrdersByCustomer Release 48 00:35.598.105 0x89cafc0 0 UIKit -[UINib instantiateWithOwner:options:]
83 OrdersByCustomer Release 47 00:35.598.110 0x89cafc0 0 UIKit -[UINib instantiateWithOwner:options:]
84 OrdersByCustomer Release 46 00:35.598.120 0x89cafc0 0 UIKit -[UINib instantiateWithOwner:options:]
85 OrdersByCustomer Release 45 00:35.598.128 0x89cafc0 0 UIKit -[UINib instantiateWithOwner:options:]
86 OrdersByCustomer Release 44 00:35.598.135 0x89cafc0 0 UIKit -[UINib instantiateWithOwner:options:]
87 OrdersByCustomer Release 43 00:35.598.142 0x89cafc0 0 UIKit -[UINib instantiateWithOwner:options:]
88 OrdersByCustomer Release 42 00:35.598.149 0x89cafc0 0 UIKit -[UINib instantiateWithOwner:options:]
89 OrdersByCustomer Release 41 00:35.598.157 0x89cafc0 0 UIKit -[UINib instantiateWithOwner:options:]
90 OrdersByCustomer Release 40 00:35.598.164 0x89cafc0 0 UIKit -[UINib instantiateWithOwner:options:]
91 OrdersByCustomer Release 39 00:35.598.171 0x89cafc0 0 UIKit -[UINib instantiateWithOwner:options:]
92 OrdersByCustomer Release 38 00:35.598.178 0x89cafc0 0 UIKit -[UINib instantiateWithOwner:options:]
93 OrdersByCustomer Release 37 00:35.598.185 0x89cafc0 0 UIKit -[UINib instantiateWithOwner:options:]
94 OrdersByCustomer Release 36 00:35.598.190 0x89cafc0 0 UIKit -[UINib instantiateWithOwner:options:]
95 OrdersByCustomer Release 35 00:35.598.200 0x89cafc0 0 UIKit -[UINib instantiateWithOwner:options:]
96 OrdersByCustomer Release 34 00:35.598.208 0x89cafc0 0 UIKit -[UINib instantiateWithOwner:options:]
97 OrdersByCustomer Release 33 00:35.598.214 0x89cafc0 0 UIKit -[UINib instantiateWithOwner:options:]
98 OrdersByCustomer Release 32 00:35.598.221 0x89cafc0 0 UIKit -[UINib instantiateWithOwner:options:]
99 OrdersByCustomer Release 31 00:35.598.228 0x89cafc0 0 UIKit -[UINib instantiateWithOwner:options:]
100 OrdersByCustomer Release 30 00:35.598.233 0x89cafc0 0 UIKit -[UINib instantiateWithOwner:options:]
101 OrdersByCustomer Release 29 00:35.598.242 0x89cafc0 0 UIKit -[UINib instantiateWithOwner:options:]
102 OrdersByCustomer Retain 30 00:35.598.276 0x89cafc0 0 Foundation -[NSKeyedUnarchiver _decodeArrayOfObjectsForKey:]
103 OrdersByCustomer Retain 31 00:35.598.358 0x89cafc0 0 Foundation -[NSKeyedUnarchiver _decodeArrayOfObjectsForKey:]
104 OrdersByCustomer Release 30 00:35.598.369 0x89cafc0 0 Foundation -[NSKeyedUnarchiver _decodeArrayOfObjectsForKey:]
105 OrdersByCustomer Retain 31 00:35.598.379 0x89cafc0 0 Foundation -[NSArray(NSArray) initWithCoder:]
106 OrdersByCustomer Release 30 00:35.598.403 0x89cafc0 0 UIKit -[UINib instantiateWithOwner:options:]
107 OrdersByCustomer Retain 31 00:35.598.507 0x89cafc0 0 Foundation -[NSKeyedUnarchiver _decodeArrayOfObjectsForKey:]
108 OrdersByCustomer Retain 32 00:35.598.594 0x89cafc0 0 Foundation -[NSKeyedUnarchiver _decodeArrayOfObjectsForKey:]
109 OrdersByCustomer Release 31 00:35.598.732 0x89cafc0 0 Foundation -[NSKeyedUnarchiver _decodeArrayOfObjectsForKey:]
110 OrdersByCustomer Retain 32 00:35.598.742 0x89cafc0 0 Foundation -[NSArray(NSArray) initWithCoder:]
111 OrdersByCustomer Release 31 00:35.598.832 0x89cafc0 0 UIKit -[UINib instantiateWithOwner:options:]
112 OrdersByCustomer Release 30 00:35.600.007 0x89cafc0 0 UIKit -[UINib instantiateWithOwner:options:]
113 OrdersByCustomer Release 29 00:35.600.036 0x89cafc0 0 UIKit -[UINib instantiateWithOwner:options:]
114 OrdersByCustomer Release 28 00:35.600.249 0x89cafc0 0 Foundation -[NSKeyedUnarchiver dealloc]
115 OrdersByCustomer Release 27 00:35.600.300 0x89cafc0 0 Foundation -[NSKeyedUnarchiver dealloc]
116 OrdersByCustomer Release 26 00:35.600.314 0x89cafc0 0 Foundation -[NSKeyedUnarchiver dealloc]
117 OrdersByCustomer Release 25 00:35.600.535 0x89cafc0 0 Foundation -[NSKeyedUnarchiver dealloc]
118 OrdersByCustomer Release 24 00:35.600.684 0x89cafc0 0 UIKit -[UIRuntimeConnection dealloc]
119 OrdersByCustomer Release 23 00:35.600.698 0x89cafc0 0 UIKit -[UIRuntimeConnection dealloc]
120 OrdersByCustomer Release 22 00:35.600.716 0x89cafc0 0 UIKit -[UIRuntimeConnection dealloc]
121 OrdersByCustomer Release 21 00:35.600.732 0x89cafc0 0 UIKit -[UIRuntimeConnection dealloc]
122 OrdersByCustomer Release 20 00:35.600.747 0x89cafc0 0 UIKit -[UIRuntimeConnection dealloc]
123 OrdersByCustomer Release 19 00:35.600.763 0x89cafc0 0 UIKit -[UIRuntimeConnection dealloc]
124 OrdersByCustomer Release 18 00:35.600.778 0x89cafc0 0 UIKit -[UIRuntimeConnection dealloc]
125 OrdersByCustomer Release 17 00:35.600.791 0x89cafc0 0 UIKit -[UIRuntimeConnection dealloc]
126 OrdersByCustomer Release 16 00:35.600.809 0x89cafc0 0 UIKit -[UIRuntimeConnection dealloc]
127 OrdersByCustomer Release 15 00:35.600.825 0x89cafc0 0 UIKit -[UIRuntimeConnection dealloc]
128 OrdersByCustomer Release 14 00:35.600.840 0x89cafc0 0 UIKit -[UIRuntimeConnection dealloc]
129 OrdersByCustomer Release 13 00:35.600.856 0x89cafc0 0 UIKit -[UIRuntimeConnection dealloc]
130 OrdersByCustomer Release 12 00:35.600.871 0x89cafc0 0 UIKit -[UIRuntimeConnection dealloc]
131 OrdersByCustomer Release 11 00:35.600.887 0x89cafc0 0 UIKit -[UIRuntimeConnection dealloc]
132 OrdersByCustomer Release 10 00:35.600.902 0x89cafc0 0 UIKit -[UIRuntimeConnection dealloc]
133 OrdersByCustomer Release 9 00:35.600.918 0x89cafc0 0 UIKit -[UIRuntimeConnection dealloc]
134 OrdersByCustomer Release 8 00:35.600.934 0x89cafc0 0 UIKit -[UIRuntimeConnection dealloc]
135 OrdersByCustomer Release 7 00:35.600.949 0x89cafc0 0 UIKit -[UIRuntimeConnection dealloc]
136 OrdersByCustomer Release 6 00:35.600.962 0x89cafc0 0 UIKit -[UIRuntimeConnection dealloc]
137 OrdersByCustomer Release 5 00:35.600.980 0x89cafc0 0 UIKit -[UIRuntimeConnection dealloc]
138 OrdersByCustomer Release 4 00:35.600.996 0x89cafc0 0 UIKit -[UIRuntimeConnection dealloc]
139 OrdersByCustomer Release 3 00:35.601.008 0x89cafc0 0 UIKit -[UIRuntimeConnection dealloc]
140 OrdersByCustomer Release 2 00:35.601.027 0x89cafc0 0 UIKit -[UIRuntimeConnection dealloc]
141 OrdersByCustomer Release 1 00:35.860.285 0x89cafc0 0 Dentanet -[CustomersRootController tableView:didSelectRowAtIndexPath:]
142 OrdersByCustomer Retain 2 00:40.062.038 0x89cafc0 0 UIKit -[UISplitViewController setViewControllers:]
143 OrdersByCustomer Release 1 00:40.140.010 0x89cafc0 0 UIKit -[UISplitViewController setViewControllers:]
144 OrdersByCustomer Release 0 00:40.140.893 0x89cafc0 0 GraphicsServices GSEventRunModal
145 OrdersByCustomer Zombie -1 00:42.129.646 0x89cafc0 0 CoreData -[NSFetchedResultsController(PrivateMethods) _managedObjectContextDidChange:]
我正在调用OrderDetailsViewController--当我尝试在此处保存上下文时出现错误:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSArray *viewControllers;
if (scOrdersInvoices.selectedSegmentIndex == INVOICES){
InvoiceDetailsViewController <SubstitutableDetailViewController> *invoiceDetailsViewController =
[[InvoiceDetailsViewController alloc] initWithNibName:@"InvoiceDetailsView" bundle:nil];
invoiceDetailsViewController.invoice = [_fetchedInvoicesResultsController objectAtIndexPath:indexPath];
invoiceDetailsViewController.tempPopoverButtonItem = self.rootPopoverButtonItem;
viewControllers = [[NSArray alloc] initWithObjects:
[appDelegate.splitViewController.viewControllers objectAtIndex:0],
invoiceDetailsViewController,
nil];
appDelegate.splitViewController.viewControllers = viewControllers;
[invoiceDetailsViewController release];
[viewControllers release];
return;
}
Orders *newOrder = [[_fetchedOrdersResultsController fetchedObjects] objectAtIndex:indexPath.row];
if (newOrder)
{
OrderDetailsViewController <SubstitutableDetailViewController> *orderDetailsViewController = [[OrderDetailsViewController alloc] initWithNibName:@"OrderDetailsView" bundle:nil];
orderDetailsViewController.tempPopoverButtonItem = self.rootPopoverButtonItem;
orderDetailsViewController.orders = newOrder;
orderDetailsViewController.iCalledFrom = 1;
NSArray *viewControllers = [[NSArray alloc]initWithObjects:
[appDelegate.splitViewController.viewControllers objectAtIndex:0],
orderDetailsViewController,
nil];
appDelegate.splitViewController.viewControllers = viewControllers;
[orderDetailsViewController release];
[viewControllers release];
}
谁能给我指出正确的方向吗?我可以看出,出于某种原因,我的上下文认为它属于它的父对象,但我不确定。把我的头发拔出来 我也面临着同样的问题,经过一次艰难而无用的调试后,我在这里找到了一篇文章,其中提供了一个有效的解决方案: 引述: 深藏在核心数据编程指南中的简单解决方案 是要确保始终将fetchedResultsController在 视图消失。我在dealloc函数中释放它,但是 这还不够--需要设置为零。以确保 立即设置为零,我实现了viewwilldiscover:并将 里面有密码。问题解决了 无论如何,我写了一条评论,要求提供苹果文档的url(因为我花了几个小时阅读,却找不到提示!!)
另外,在我的代码中,我添加了一个对[super ViewWillEnglish:animated]的调用;:P
不要将fetchedResultsController设置为nil,而是将其委托设置为nil。是委托调用controllerWillChangeContent并导致崩溃
我个人会在视图隐藏后删除代理,并在可见时再次添加代理- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
// Start listening for updates when visable
self.fetchedResultsController.delegate = self;
}
- (void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
// Stop listening for updates when not visable
self.fetchedResultsController.delegate = nil;
}
我不确定这里是否有足够的应用程序结构可见,但这听起来像是委托模式和内存管理的一般问题,而不是
NSFetchedResultsController
特有的问题
一般的问题似乎是对象A是对象B的委托,而对象A已被解除分配,但B不知道这一点。B一直试图向A发送消息,因为有人告诉它这样做。这将导致发送到解除分配实例的消息发生错误和崩溃。在本例中,B是一个NSFetchedResultsController
,但它可以是使用委托的任何类的实例。我在NSURLConnection
中看到过类似的问题
这里给出的其他答案以不同的方式避免了崩溃。使用
self.fetchedResultsController = nil;
之所以有效,是因为假定@property
声明正确,它将取消分配获取的结果控制器。这可能是正确的解决方案,但同样取决于整个应用程序结构
使用
避免崩溃,但不会取消分配获取的结果控制器。这可以防止应用程序崩溃,但可能会导致内存泄漏。在某个地方,有一个泄露的获取结果控制器,没有委托人可以交谈,也没有人向它询问信息。在上面的描述中,B仍然存在,但由于其委托为nil
,它将不再尝试向解除分配的A发送消息。不确定原因,但问题似乎是在程序开始时的实际managedobjectcontext中出现的。我浏览并添加了[managedObjectContext release];managedObjectContext=nil;在[解除锁定]的过程中,它似乎已经治愈了它(目前)。为什么?不知道。我不知道你剩下的代码,但我有完全相同的问题。用实体填充的UITableView。是什么(显然)导致了问题,在表视图上选择一条记录并将NSManagedObject实体作为参数传递给detail view控制器。我解决了传递NSManagedObjectID并从商店获取对象的问题。我也遇到了与Alan相同的问题,您的帖子帮助我找到了解决方案。谢谢呜!这有帮助。还有,有道理。太棒了!很好的答案解决了我的问题。发现这是真的,即使使用ARC。谢谢汤姆!在进一步挖掘之后,我意识到ARC将取消分配获取的结果控制器,但我仍然有责任取消委托。添加fetchedResultsController.delegate=nil的dealloc修复了它。我以为我已经完成了dealloc的实现,但我想没有:-\@PhilipLoden谢谢。添加dealloc和fetchedResultsController=nil修复了我半天来一直在调查的问题。
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
// Start listening for updates when visable
self.fetchedResultsController.delegate = self;
}
- (void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
// Stop listening for updates when not visable
self.fetchedResultsController.delegate = nil;
}
self.fetchedResultsController = nil;
self.fetchedResultsController.delegate = nil