iphone - What Does This NSZombie Error Message Mean? -


i turned zombies on because getting crashes. i' getting error in console. know means?

*** -[routinedaytableviewcontroller retain]: message sent deallocated instance 0x7464150

@implementation routinedaytableviewcontroller  @synthesize fetchedresultscontroller; @synthesize exercisechooserview; @synthesize routinetableview; @synthesize managedobjectcontext; @synthesize selectedexercise; @synthesize theselectedroutine;  - (void)dealloc {     nslog(@"dealloc");     [fetchedresultscontroller release];     [selectedexercise release];     [managedobjectcontext release];     [exercisechooserview release];     [routinetableview release];     [theselectedroutine release];     [super dealloc]; }  - (void)didreceivememorywarning {     // releases view if doesn't have superview.     [super didreceivememorywarning]; }  #pragma mark - view lifecycle  - (void)viewdidload {     [super viewdidload];      self.routinetableview.delegate = self;     if (managedobjectcontext == nil)      {          managedobjectcontext = [(curlappdelegate *)[[uiapplication sharedapplication] delegate] managedobjectcontext];          [managedobjectcontext retain];     } }  - (void)viewdidunload {     nslog(@"viewdidunload");     [super viewdidunload];     self.exercisechooserview = nil;     self.routinetableview = nil;     self.fetchedresultscontroller = nil; }  #pragma mark - exercise editing  -(ibaction)exercisechooser {     routineexercisechooserviewcontroller *routineexercisechooserviewcontroller = [[[routineexercisechooserviewcontroller alloc] init] autorelease];     [self.navigationcontroller pushviewcontroller:routineexercisechooserviewcontroller animated:yes]; }  -(void)addexercise {        if (managedobjectcontext == nil)      {          managedobjectcontext = [(curlappdelegate *)[[uiapplication sharedapplication] delegate] managedobjectcontext];          [managedobjectcontext retain];     }      uibarbuttonitem *addbutton = [[uibarbuttonitem alloc]initwithbarbuttonsystemitem:uibarbuttonsystemitemadd target:self action:@selector(exercisechooser)];     self.navigationitem.rightbarbuttonitem = addbutton;     [addbutton release];      nserror *error = nil;      exercise *exercise = (exercise *)[nsentitydescription insertnewobjectforentityforname:@"exercise" inmanagedobjectcontext:managedobjectcontext];      exercise.name = self.selectedexercise;      nslog(@"addexercise theselectedroutine:  %@", theselectedroutine);      [self.theselectedroutine addroutinetoexercisesobject:exercise];      if (![fetchedresultscontroller.managedobjectcontext save:&error])      {         // handle error.     }     nslog(@"%@", error);     nslog(@"addexercise theselectedroutine:  %@", theselectedroutine); }    #pragma mark - table view data source  - (nsinteger)numberofsectionsintableview:(uitableview *)tableview {     return [[self.fetchedresultscontroller sections] count]; }  - (nsinteger)tableview:(uitableview *)tableview numberofrowsinsection:(nsinteger)section {     id <nsfetchedresultssectioninfo> sectioninfo = [[self.fetchedresultscontroller sections] objectatindex:section];     return [sectioninfo numberofobjects]; }  - (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath {     static nsstring *cellidentifier = @"cell";      uitableviewcell *cell = [routinetableview dequeuereusablecellwithidentifier:cellidentifier];     if (cell == nil) {         cell = [[[uitableviewcell alloc] initwithstyle:uitableviewcellstyledefault reuseidentifier:cellidentifier] autorelease];     }      exercise *tempexercise = (exercise *)[fetchedresultscontroller objectatindexpath:indexpath];     cell.textlabel.text = tempexercise.name;      return cell; }  -(void)tableview:(uitableview *)tableview commiteditingstyle:(uitableviewcelleditingstyle)editingstyle forrowatindexpath:(nsindexpath *)indexpath {     if (editingstyle == uitableviewcelleditingstyledelete)      {         // delete managed object given index path         nsmanagedobjectcontext *context = [self.fetchedresultscontroller managedobjectcontext];         [context deleteobject:[self.fetchedresultscontroller objectatindexpath:indexpath]];         nslog(@"fetched results : \n%@\n",[self.fetchedresultscontroller fetchedobjects]);          // commit change.         nserror *error = nil;          // update array , table view.         if (![fetchedresultscontroller.managedobjectcontext save:&error])          {             // handle error.         }         //[tableview deleterowsatindexpaths:[nsarray arraywithobject:indexpath] withrowanimation:yes];     } }  - (void)configurecell:(uitableviewcell *)cell atindexpath:(nsindexpath *)indexpath {     nsmanagedobject *managedobject = [self.fetchedresultscontroller objectatindexpath:indexpath];     cell.textlabel.text = [[managedobject valueforkey:@"name"] description]; }  #pragma mark - table view delegate  - (void)tableview:(uitableview *)tableview didselectrowatindexpath:(nsindexpath *)indexpath {     // navigation logic may go here. create , push view controller.     [routinetableview deselectrowatindexpath:indexpath animated:yes];      detailviewcontroller *detailviewcontroller = [[detailviewcontroller alloc] initwithnibname:@"detailviewcontroller" bundle:nil];      // pass selected object new view controller.      [self.navigationcontroller pushviewcontroller:detailviewcontroller animated:yes];      [detailviewcontroller release]; }  #pragma mark - fetched results controller  - (nsfetchedresultscontroller *)fetchedresultscontroller {     if (fetchedresultscontroller != nil)     {         return fetchedresultscontroller;     }      // create fetch request entity.     nsfetchrequest *fetchrequest = [[nsfetchrequest alloc] init];     // edit entity name appropriate.     nsentitydescription *entity = [nsentitydescription entityforname:@"exercise" inmanagedobjectcontext:self.managedobjectcontext];     [fetchrequest setentity:entity];     nslog(@"fetchedresultscontroller theselectedroutine: %@",theselectedroutine);     [fetchrequest setpredicate:[nspredicate predicatewithformat: @"any exercisetoroutine == %@", theselectedroutine]];      // set batch size suitable number.     [fetchrequest setfetchbatchsize:20];      // edit sort key appropriate.     nssortdescriptor *sortdescriptor = [[nssortdescriptor alloc] initwithkey:@"name" ascending:no];     nsarray *sortdescriptors = [[nsarray alloc] initwithobjects:sortdescriptor, nil];      [fetchrequest setsortdescriptors:sortdescriptors];      // edit section name key path , cache name if appropriate.     // nil section name key path means "no sections".     nsfetchedresultscontroller *afetchedresultscontroller = [[nsfetchedresultscontroller alloc] initwithfetchrequest:fetchrequest managedobjectcontext:self.managedobjectcontext sectionnamekeypath:nil cachename:nil];     afetchedresultscontroller.delegate = self;     self.fetchedresultscontroller = afetchedresultscontroller;      nserror *error = nil;     if (![self.fetchedresultscontroller performfetch:&error])     {         /*          replace implementation code handle error appropriately.           abort() causes application generate crash log , terminate. should not use function in shipping application, although may useful during development. if not possible recover error, display alert panel instructs user quit application pressing home button.          */         nslog(@"unresolved error %@, %@", error, [error userinfo]);         abort();     }      [afetchedresultscontroller release];     [fetchrequest release];     [sortdescriptor release];     [sortdescriptors release];     return fetchedresultscontroller; }      #pragma mark - fetched results controller delegate  - (void)controllerwillchangecontent:(nsfetchedresultscontroller *)controller {     [self.routinetableview beginupdates]; }  - (void)controller:(nsfetchedresultscontroller *)controller didchangesection:(id <nsfetchedresultssectioninfo>)sectioninfo            atindex:(nsuinteger)sectionindex forchangetype:(nsfetchedresultschangetype)type {     switch(type)     {         case nsfetchedresultschangeinsert:             [self.routinetableview insertsections:[nsindexset indexsetwithindex:sectionindex] withrowanimation:uitableviewrowanimationfade];             break;          case nsfetchedresultschangedelete:             [self.routinetableview deletesections:[nsindexset indexsetwithindex:sectionindex] withrowanimation:uitableviewrowanimationfade];             break;     } }  - (void)controller:(nsfetchedresultscontroller *)controller didchangeobject:(id)anobject        atindexpath:(nsindexpath *)indexpath forchangetype:(nsfetchedresultschangetype)type       newindexpath:(nsindexpath *)newindexpath {     uitableview *tableview = self.routinetableview;      switch(type)     {          case nsfetchedresultschangeinsert:             [tableview insertrowsatindexpaths:[nsarray arraywithobject:newindexpath] withrowanimation:uitableviewrowanimationfade];             break;          case nsfetchedresultschangedelete:             [tableview deleterowsatindexpaths:[nsarray arraywithobject:indexpath] withrowanimation:uitableviewrowanimationfade];             break;          case nsfetchedresultschangeupdate:             [self configurecell:[tableview cellforrowatindexpath:indexpath] atindexpath:indexpath];             break;          case nsfetchedresultschangemove:             [tableview deleterowsatindexpaths:[nsarray arraywithobject:indexpath] withrowanimation:uitableviewrowanimationfade];             [tableview insertrowsatindexpaths:[nsarray arraywithobject:newindexpath]withrowanimation:uitableviewrowanimationfade];             break;     } }  - (void)controllerdidchangecontent:(nsfetchedresultscontroller *)controller {     [self.routinetableview endupdates]; }  @end 

update, method in viewcontroller. causing problem?

    - (void)tableview:(uitableview *)tableview didselectrowatindexpath:(nsindexpath *)indexpath     {         [tableview deselectrowatindexpath:indexpath animated:yes];          nsstring *selectedrow = [[self.exercisearray objectatindex:indexpath.row]objectforkey:@"exercisename"];         nslog(@"row selected: %@", selectedrow);          routinedaytableviewcontroller *routinedaytableviewcontroller=[self.navigationcontroller.viewcontrollers objectatindex:([self.navigationcontroller.viewcontrollers count] -3)];          routinedaytableviewcontroller.selectedexercise = selectedrow;         [routinedaytableviewcontroller addexercise];         [routinedaytableviewcontroller release];          [self dismissview];   } 

and here method in yet viewcontroller access class:

- (void)tableview:(uitableview *)tableview didselectrowatindexpath:(nsindexpath *)indexpath {     [tableview deselectrowatindexpath:indexpath animated:yes];       routinedaytableviewcontroller *detailviewcontroller = [[routinedaytableviewcontroller alloc] initwithnibname:@"routinedaytableviewcontroller" bundle:nil];     nsmanagedobject *managedobject = [self.fetchedresultscontroller objectatindexpath:indexpath];      detailviewcontroller.title = [[managedobject valueforkey:@"name"] description];      detailviewcontroller.theselectedroutine = [__fetchedresultscontroller objectatindexpath: indexpath];     nslog(@"detailviewcontroller.theselectedroutine:%@",detailviewcontroller.theselectedroutine);     [self.navigationcontroller pushviewcontroller:detailviewcontroller animated:yes];     [detailviewcontroller release]; } 

the error message means sending message object retain count went 0 , subsequently deallocated. based on code snippet, think problem code -

    routinedaytableviewcontroller *routinedaytableviewcontroller=[self.navigationcontroller.viewcontrollers objectatindex:([self.navigationcontroller.viewcontrollers count] -3)];      routinedaytableviewcontroller.selectedexercise = selectedrow;     [routinedaytableviewcontroller addexercise];     [routinedaytableviewcontroller release]; 

the release call here looks suspicious. releasing haven't alloced here.

have run static analyzer on code? helpful in detecting bugs of kind.


Comments