ios - NSFetchedResultsController crash on -controllerDidChangeContent: in iPad -
nsfetchedresultscontroller crashes on -controllerdidchangecontent: on inserting new record , saving persistentstore.
code:
- (void)controller:(nsfetchedresultscontroller *)controller didchangeobject:(id)anobject atindexpath:(nsindexpath *)indexpath forchangetype:(nsfetchedresultschangetype)type newindexpath:(nsindexpath *)newindexpath { nslog(@"== updating indexpath (%@) newindexpath (%@) type %i", indexpath, newindexpath, (int)type); switch (type) { case nsfetchedresultschangedelete: { [self.tableview deleterowsatindexpaths:@[indexpath] withrowanimation:uitableviewrowanimationtop]; break; } case nsfetchedresultschangeinsert: { [self.tableview insertrowsatindexpaths:@[newindexpath] withrowanimation:uitableviewrowanimationbottom]; break; } case nsfetchedresultschangemove: { [self.tableview moverowatindexpath:indexpath toindexpath:newindexpath]; break; } case nsfetchedresultschangeupdate: { [self.tableview reloadrowsatindexpaths:@[indexpath] withrowanimation:uitableviewrowanimationtop]; break; } default: break; } } - (void)controllerwillchangecontent:(nsfetchedresultscontroller *)controller { nslog(@"== begin updating"); [self.tableview beginupdates]; } - (void)controllerdidchangecontent:(nsfetchedresultscontroller *)controller { nslog(@"== end updating"); [self.tableview endupdates]; }
note:- in target application fetchedresults delegate implemented in uitableviewcontroller subclass. , fetchedresultscontroller working child managed object context.
possible sources of error (please provide error message):
- moc provides data frc not of
nsmainqueueconcurrencytype
. -controller:didchangesection:atindex:forchangetype:
not implemented.
Comments
Post a Comment