iphone - What should I watch to debug this Core-Data / NSFetchedResultsController bug? -


i've got bug in core data implementation cannot seem hold of, , need tips on should looking figure out how fix it.

to make long story short, have uitableview being populated nsfetchedresultscontroller. want users able change sorting options data, give them picker change underlying fetchedresultscontroller different preset configurations. can change , forth between different fetchedresultscontrollers no issue whatsoever. can add , remove data, never experiencing crashes, no problem. however, on 2 (out of 6, , same 2) of fetchedresultcontroller configurations, items added database not added tableview. , items in tableview disappear once edited.

here steps go through reproduce bug:

  1. set sorting configuration works
  2. add new item database (at point controllerwillchangecontent fires)
  3. change configuration doesn't work
  4. add new item database (controllerwillchangecontent not fire)
  5. switch working configuration
  6. the item added visible in tableview
  7. switch non-working configuration
  8. the item visible in tableview
  9. edit item (controllerwillchangecontent fired, controller:didchangeobject: fired type nsfetchedresultschangedelete instead of nsfetchedresultschangeupdate)
  10. change working configuration, , item changed , visible again.

i'm @ wits end thing. i'm out of ideas. there literally no difference between way these 2 fetchedresultscontrollers created , 4 others. any can offered greatly appreciated.

--edit--

still having issues this. reiterate of answers techzen's questions:

  • none of attributes set transient values
  • i'm using flat model @ moment. it's single entity direct attributes. there no relationships.
  • the problem persists caches set nil
  • i setting old frc's delegate nil before every change, , setting new frc's delegate self @ end of switch. consistant across 6 frcs
  • i releasing old frc , creating new 1 each time user switches different sort option.

for interested, code i'm using switch frc in gist here

-- edit 2 --

starting bounty can point me in right direction on this.

-- edit 3 --

as requested, here code delegate methods:

-(void)controllerwillchangecontent:(nsfetchedresultscontroller *)controller {     [self.tableview beginupdates]; }  -(void)controller:(nsfetchedresultscontroller *)controller didchangesection:(id<nsfetchedresultssectioninfo>)sectioninfo atindex:(nsuinteger)sectionindex forchangetype:(nsfetchedresultschangetype)type {     switch (type) {         case nsfetchedresultschangeinsert:             [self.tableview insertsections:[nsindexset indexsetwithindex:sectionindex] withrowanimation:uitableviewrowanimationfade];             break;          case nsfetchedresultschangedelete:             [self.tableview deletesections:[nsindexset indexsetwithindex:sectionindex] withrowanimation:uitableviewrowanimationfade];             break;      } }  -(void)controller:(nsfetchedresultscontroller *)controller didchangeobject:(id)anobject atindexpath:(nsindexpath *)indexpath forchangetype:(nsfetchedresultschangetype)type newindexpath:(nsindexpath *)newindexpath {     switch (type) {         case nsfetchedresultschangeinsert:             [self.tableview insertrowsatindexpaths:[nsarray arraywithobject:newindexpath] withrowanimation:uitableviewrowanimationfade];             break;         case nsfetchedresultschangedelete:             [self.tableview deleterowsatindexpaths:[nsarray arraywithobject:indexpath] withrowanimation:uitableviewrowanimationfade];             break;         case nsfetchedresultschangeupdate:             if (!self.searchisactive) {                 [self configurecell:[self.tableview cellforrowatindexpath:indexpath] atindexpath:indexpath];             } else {                 [self.searchdisplaycontroller.searchresultstableview reloaddata];             }             break;         case nsfetchedresultschangemove:             [self.tableview deleterowsatindexpaths:[nsarray arraywithobject:indexpath] withrowanimation:uitableviewrowanimationfade];             [self.tableview insertrowsatindexpaths:[nsarray arraywithobject:newindexpath] withrowanimation:uitableviewrowanimationfade];             break;     }  }   -(void)controllerdidchangecontent:(nsfetchedresultscontroller *)controller {     [self.tableview endupdates];  } 

and info got data model:

// person.h #import <coredata/coredata.h> @interface person :  nsmanagedobject   { }  @property (nonatomic, retain) nsstring * name; @property (nonatomic, retain) nsstring * company; @property (nonatomic, retain) nsstring * comments; @property (nonatomic, retain) nsstring * job; @property (nonatomic, retain) nsdate * logdate; @property (nonatomic, retain) nsstring * location; @property (nonatomic, retain) nsnumber * rating; @property (nonatomic, retain) nsstring * imagepath; @property (nonatomic, retain) nsstring * thumbpath;  @end  // person.m #import "person.h"  @implementation person   @dynamic name; @dynamic company; @dynamic comments; @dynamic job; @dynamic logdate; @dynamic location; @dynamic rating; @dynamic imagepath; @dynamic thumbpath;  @end 

info data model:

entity: person     property: comments         kind: attribute         type: string         optional: yes     property: name         kind: attribute         type: string         optional: no     property: rating         kind: attribute         kind: int 16         optional: yes         min value: 0         max value: 5     property: job         kind: attribute         kind: string         optional: yes     property: company         kind: attribute         kind: string         optional: yes     property: location         kind: attribute         kind: string         optional: yes     property: imagepath         kind: attribute         kind: string         optional: yes     property: thumbpath         kind: attribute         kind: string         optional: yes     property: logdate         kind: attribute         kind: date         optional: yes 

nothing special of this.

i reposting comment answer, requested.

both "job" , "location" attributes optional. new item add in 1 of broken configuration contain values these attributes? may item not added table because, owing attributes values , nsfetchedresultscontroller setup, not fetched @ all. same reasons, may that, once edited, item disappear table (because no longer belong table after editing).

edit:

to set initial value different nil, in core data person.m file add following method

- (void) awakefrominsert{     self.job = @"";     self.location = @""; } 

etc. way, initial values automatically inserted core data each time create new person object.


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -