[controllerWillChangeContent:]:发送到解除分配实例的消息

时间:2011-07-28 13:52:10

标签: ipad memory-management xcode4 nsfetchedresultscontroller nsmanagedobjectcontext

我的ipad应用程序出现问题。

我有一个可以通过两种方式访问​​的视图,如果我以一种方式进行完美运行。如果我通过另一个进入,它会在保存上下文时崩溃。

我怀疑它是父母的东西(客户的订单) - 我收到一个带有消息的僵尸:

[OrdersByCustomer controllerWillChangeContent:]:发送到解除分配的实例的消息0x10102020 当我通过Zombies的仪器运行时,我得到了:

#   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];

}       

} `

然后在OrdersDetailViewController中我的viewDidLoad:

 - (void)viewDidLoad
 {
appDelegate = (D4AppDelegate *)[[UIApplication sharedApplication]delegate];
self.managedObjectContext = appDelegate.managedObjectContext;
HistoryOrCatalogController *hoc = [[HistoryOrCatalogController alloc] initWithNibName:@"HistoryOrCatalogController" bundle:[NSBundle mainBundle]];
hoc.delegate = self;
UIPopoverController *po = [[UIPopoverController alloc]initWithContentViewController:hoc];
po.popoverContentSize = CGSizeMake(200.0, 90.0);
[hoc release];
self.searchPopover = po;
[po release];

[super viewDidLoad];
total = 0.0f;
qtyAddedToOrder = 0;
if (iCalledFrom == 1) {
    UIBarButtonItem *bi = [[[UIBarButtonItem alloc] initWithTitle:@"Back" style:UIBarButtonItemStyleBordered target:self action:@selector(back)]autorelease];
    [navigationBar.topItem setLeftBarButtonItem:bi animated:YES];

}
NSError *error;
orderID = orders.OrderID;
if(![[self fetchedResultsController] performFetch:&error]){
    NSLog(@"Order Error: %@, %@", error, [error userInfo]);
}
[self updateInterface];

self.navigationBar.topItem.title = [NSString stringWithFormat:@"Order # %d", [orders.OrderID intValue]];


 }

有人能指出我正确的方向吗?我可以看到,由于某种原因,我的上下文认为它属于它的父母,但我不确定。拉出我的头发!

3 个答案:

答案 0 :(得分:17)

我遇到了同样的问题,经过艰苦无用的调试后,我在这里发现了一个有效的解决方案:http://tinymission.com/blog/blogengine.web/post/2011/03/04/NSFetchedResultsController-and-EXC_BAD_ACCESS.aspx

引用:

  

深入埋藏在核心数据编程指南中的简单解决方案   是的,以确保始终将fetchedResultsController设置为nil之后   视图消失了。我在dealloc函数中释放它,但那   还不够 - 它需要设置为零。确保它得到   设置为nil,我实现了viewWillDisappear:并把它放了   代码在那里。问题解决了!

-(void)viewWillDisappear:(BOOL)animated {
 self.fetchedResultsController = nil;
}
无论如何,我写了一篇评论,要求提供苹果文档的网址(因为我在没有找到小费的情况下花了几个小时阅读它!)

PS。在我的代码中我添加了对[super viewWillDisappear:animated]的调用; :P

答案 1 :(得分:9)

不是将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;
}

答案 2 :(得分:2)

我不确定此处可见的应用程序结构是否足够确定,但这听起来像委托模式和内存管理的一般问题,而不是NSFetchedResultsController特有的任何内容。

一般问题出现是对象A是对象B的委托,而对象A已经解除分配但是B不知道。 B一直试图向A发送消息,因为这是被告知要做的事情。这导致message sent to deallocated instance错误和崩溃。在这种情况下,B是NSFetchedResultsController,但它可以是使用委托的任何类的实例。我在NSURLConnection看到了类似的问题。

此处给出的其他答案以不同方式避免崩溃。使用

self.fetchedResultsController = nil;

有效,因为假设@property声明是正确的,它会取消分配获取的结果控制器。这可能是正确的解决方案,但同样取决于整体应用程序结构。

使用

self.fetchedResultsController.delegate = nil

避免崩溃,但不释放取出的结果控制器。这可以防止应用程序崩溃但可能导致内存泄漏。在某个地方,有一个泄露的取得结果控制器没有代表与之交谈,没有人要求它提供信息。在上面的描述中,B仍然存在,但由于其委托是nil,它将不再尝试向已释放的A发送消息。