ios - Core Data memory leak when I use UINavigationController -
i used xcode template create master-detail app , using core data. check app instruments (memory leaks) , see memory leaks when go detail view master view.
memory leaks appear when i:
- select row in table , go master view detail view
- edit value , click button clicksave in detailview
- click on button in uinavigationcontroller
my code:
masterviewcontroller.m: @implementation masterviewcontroller ..... - (void)prepareforsegue:(uistoryboardsegue *)segue sender:(id)sender { if ([[segue identifier] isequaltostring:@"showdetail"]) { nsindexpath *indexpath = [self.tableview indexpathforselectedrow]; event *object = [[self fetchedresultscontroller] objectatindexpath:indexpath]; [[segue destinationviewcontroller] setdetailitem:object]; } } detailviewcontroller.h: #import <uikit/uikit.h> #import "event.h" @interface detailviewcontroller : uiviewcontroller <uitextviewdelegate> @property (strong, nonatomic) event *detailitem; @end detailviewcontroller.m: - (ibaction)clicksave:(id)sender { self.detailitem.mytext = self.textview.text; nserror *error; if (![self.detailitem.managedobjectcontext save:&error]) { nslog(@"unresolved error %@, %@", error, [error userinfo]); abort(); } }
Comments
Post a Comment