Sometimes the reader and the first question are asked, so please be careful :)
I create a Managed Object (account), which is passed to the controller of the child view, where it is set in the saved property.
Account * account = [[Account alloc] initWithEntity:entity insertIntoManagedObjectContext:context]; AddAccountViewController *childController = [[AddAccountViewController alloc] init]; childController.title = @"Account Details"; childController.anAccount = account; childController.delegate = self; [self.navigationController pushViewController:childController animated:YES]; [childController release]; [account release];
View Controller Interface:
@interface AddAccountViewController : UIViewController { } @property (nonatomic, retain) IBOutlet UITextField * usernameTextField; @property (nonatomic, retain) IBOutlet UITextField * passwordTextField; @property (nonatomic, retain) Account * anAccount; @property (nonatomic, assign) id <AddAccountDelegate> delegate; - (IBAction)cancel:(id)sender; - (IBAction)add:(id)sender; - (IBAction)textFieldDone:(id)sender; @end
So, in code example 1, I released an account object because I am no longer interested in this method. Since it is saved by the AddAccountViewController , I have an entry in the AddAccountViewController dealloc that releases it.
However, when I go to remove the object from the ManagedObjectContext , the application crashes with the following (rather obscure) error:
Detected an attempt to call a symbol in system libraries that is not present on the iPhone: _Unwind_Resume called from function _PFFaultHandlerLookupRow in image CoreData.
After a lot of debugging and hair pulling, I found that if I didn’t release the account in the AddAccountViewController dealloc method , the application worked correctly constantly and did not seem to flow according to the tools.
Can anyone shed light on what is happening? I understand from the docs about the properties that need to be saved. What did I miss?
Refresh to answer Kevin's question
The code for deleting an object from a ManagedObjectContext is in the RootViewController (which contains the child controller)
ios objective-c iphone cocoa-touch core-data
tarasis
source share