3

我的ipad應用程序出現問題。[controllerWillChangeContent:]:發送到釋放實例的消息

我有兩種方式訪問​​的視圖,如果我以一種完美的方式進行訪問。如果我通過另一個進入,它保存上下文時會崩潰。

我懷疑這事是在父(按客戶訂單) - 我得到一個殭屍與消息:

[OrdersByCustomer controllerWillChangeContent:]:消息發送到釋放實例0x10102020 當我通過intstruments運行與殭屍我得到:

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


} 

任何人都可以點我在正確的方向?我可以看到,出於某種原因,我的上下文認爲它屬於它的父項,但我不確定。把我的頭髮拉出來!

+0

不知道爲什麼,但似乎問題出在程序開始時的實際managedobjectcontext中。我經歷了並添加了[managedObjectContext release]; managedObjectContext = nil;在[dealloc]的一路上,它似乎已經治好了它(現在)。爲什麼?不知道。 。 。 –

+1

不知道你的其他代碼,但我有完全相同的問題。一個用實體填充的UITableView。什麼是(顯然)導致這個問題,在表視圖上選擇一個記錄,並將NSManagedObject實體作爲參數傳遞給詳細視圖控制器。我解決了傳遞NSManagedObjectID,並從商店獲取對象。 – Leonardo

回答

17

我面臨同樣的問題和艱難的和無用的調試之後,我發現了一個有效的解決方案的一則訊息:http://tinymission.com/blog/blogengine.web/post/2011/03/04/NSFetchedResultsController-and-EXC_BAD_ACCESS.aspx

報價:

核心數據編程中深埋指導簡單的解決方案 將確保在 視圖消失後始終將fetchedResultsController設置爲零。我在dealloc函數中釋放它,但是 還不夠 - 它需要設置爲零。爲了確保 設置爲零,我實現了viewWillDisappear:並將 代碼放在那裏。問題解決了!

-(void)viewWillDisappear:(BOOL)animated { 
self.fetchedResultsController = nil; 
} 

反正我寫了評論,要求一個URL,蘋果文件(因爲我失去小時沒有找到尖端!!讀它)

PS。在我的代碼中,我添加了對[super viewWillDisappear:animated]的調用; :P

+0

我也遇到了和Alan一樣的問題,你的文章幫助我找到了解決方案。謝謝! – Marcin

+0

Woot!這有幫助。另外,有道理。 –

+0

太棒了!很好的答案,解決了我的問題。 – Convolution

9

不是將fetchedResultsController設置爲零,而是將它的委託設置爲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

我不知道有足夠的應用程序的結構,可見這裏可以肯定的,但是這聽起來像是與委託模式和內存管理,而具體到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了。

+0

謝謝湯姆!在深入挖掘之後,我意識到ARC會將取出的結果控制器解除分配,但我仍然有責任將該委託進行清零。添加dealloc fetchedResultsController.delegate = nil 修復了它。我以爲我完成dealloc,但我不想: - \ –

+0

@PhilipLoden謝謝。添加一個dealloc和fetchedResultsController =零解決了我的問題我正在調查半天。 –

相關問題