开发者

[ controllerWillChangeContent:]: message sent to deallocated instance

I am having a problem with my ipad app.

I've got a view that is accessed in 2 ways, if i go in one way it works perfectly. If I go in through another though, it crashes when saving the context.

I suspect it is something in the parent (orders by customer) -- I get a zombie with the message:

[OrdersByCustomer controllerWillChangeContent:]: message sent to deallocated instance 0x10102020 when I run it through intstruments with Zombies I get:

#   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    Aut开发者_如何学Goorelease     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:]

I am calling OrderDetailsViewController -- where the error occurs when I try to save the context here:

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

}       

} `

and then in OrdersDetailViewController my 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]];


 }

Can anyone point me in the right direction? I can see that for some reason my context thinks it belongs to its parent, but i'm not sure. Pulling my hair out!


I was facing the same issue and after an hard and useless debug, I found a post here with an effective solution: http://tinymission.com/blog/blogengine.web/post/2011/03/04/NSFetchedResultsController-and-EXC_BAD_ACCESS.aspx

Quote:

Buried deep within the Core Data programming guide the simple solution was to be sure to always set fetchedResultsController to nil after the view disappears. I was releasing it in the dealloc function, but that wasn’t enough -- it needs to be set to nil. To make sure that it gets set to nil right away, I implemented viewWillDisappear: and put the code in there. Problem solved!

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

anyway I wrote a comment asking for an url to the apple documentation (since I lost hours to read it without finding the tip!!)

ps. in my code I added a call to [super viewWillDisappear:animated]; :P


Instead of setting fetchedResultsController to nil, set it's delegate to nil. It's the delegate which is calling controllerWillChangeContent and causing the crash

I personally remove the delegate once the view is hidden and add it again when visible.

- (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;
}


I'm not sure there's enough of the app's structure visible here to be sure but this sounds like a general problem with the delegate pattern and memory management, and not anything specific to NSFetchedResultsController.

The general problem appears to be one where object A is a delegate for object B, and object A has been deallocated but B doesn't know that. B keeps trying to send messages to A because that's what it's been told to do. That leads to the message sent to deallocated instance error and a crash. In this case B is an NSFetchedResultsController but it could be an instance of any class using delegation. I've seen similar problems with NSURLConnection.

Other answers given here avoid the crash in different ways. Using

self.fetchedResultsController = nil;

works because, assuming the @property declaration is correct, it deallocates the fetched results controller. This is probably the right solution, but again it depends on the overall app structure.

Using

self.fetchedResultsController.delegate = nil

avoids the crash but does not deallocate the fetched results controller. This prevents the app from crashing but probably leads to a memory leak. Somewhere, there's a leaked fetched results controller with no delegate to talk to and nobody asking it for information. In the description above, B still exists but since its delegate is nil it won't try to send messages to the deallocated A anymore.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜