iphone - Core data: Serious application error -


i'm finishing core data app ans started final testing.

everyfing works fine, except 1 thing, happens randomly , can't reproduce it.

here log (with nszombieenabled):

2011-07-03 20:27:53.144 myapp[1882:707] -[__nscftype controllerwillchangecontent:]: unrecognized selector sent instance 0x4a4c490 2011-07-03 20:27:53.149 myapp[1882:707] serious application error.  exception caught during core data change processing.  bug within observer of nsmanagedobjectcontextobjectsdidchangenotification.  -[__nscftype controllerwillchangecontent:]: unrecognized selector sent instance 0x4a4c490 userinfo (null) 2011-07-03 20:27:53.165 myapp[1882:707] coreanimation: ignoring exception: -[__nscftype controllerwillchangecontent:]: unrecognized selector sent instance 0x4a4c490 

it crashes here:

nsmanagedobjectcontext *context = [(appdelegate *)[[uiapplication sharedapplication] delegate] managedobjectcontext]; // it's ok nsmanagedobject *newmanagedobject = [nsentitydescription insertnewobjectforentityforname:@"kontrahent" inmanagedobjectcontext:context]; // it's ok for(nsstring *key in kontrahent) [newmanagedobject setvalue:[kontrahent valueforkey:key] forkey:key];  // it's ok nserror *error = nil; if (![context save:&error]) {  // it's not ok     nslog(@"unresolved error %@, %@", error, [error userinfo]);     abort(); } 

my action hierarchy:

1. open application 2. open 'root' list (with nsfetchedresultscontroller, entity: "faktura") 3. tap 'add' button 4. in 'add' view controller create object (entity: "kontrahent") 5. try add database 6. crashes / doesn't.  scheme:          +---[moc save:]---> faktury (my root class)         |                        ↓         +-----delegate-- fakturacreator <---[moc save:]--+  <--- here crashes                                  ↓                       |                          kontrahentcreator ---delegate---+ 

i know it's connected nsfetchedresultscontroller , [moc save:]. can't locate problem, because crashes when wants. works, crashes. if know abou problem, please me :)


if need more code...

nsfetchedresultscontroller stuff (faktury.m)

#pragma mark - fetched results controller  - (nsfetchedresultscontroller *)fetchedresultscontroller {      if (__fetchedresultscontroller != nil) return __fetchedresultscontroller;      // setup table      nsfetchrequest *fetchrequest = [[nsfetchrequest alloc] init];     nsentitydescription *entity = [nsentitydescription entityforname:@"faktura" inmanagedobjectcontext:self.managedobjectcontext];     [fetchrequest setentity:entity];      // setup sort descriptors      nssortdescriptor *sortdescriptor = [[nssortdescriptor alloc] initwithkey:@"numerfv" ascending:yes];     nsarray *sortdescriptors = [[nsarray alloc] initwithobjects:sortdescriptor, nil];     [fetchrequest setsortdescriptors:sortdescriptors];      // create fetched results controller      nsfetchedresultscontroller *afetchedresultscontroller = [[nsfetchedresultscontroller alloc] initwithfetchrequest:fetchrequest managedobjectcontext:self.managedobjectcontext sectionnamekeypath:nil cachename:@"root"];     afetchedresultscontroller.delegate = self;     self.fetchedresultscontroller = afetchedresultscontroller;      [afetchedresultscontroller release];     [fetchrequest release];     [sortdescriptor release];     [sortdescriptors release];      nserror *error = nil;     if (![self.fetchedresultscontroller performfetch:&error]) {          uialertview *alert = [[uialertview alloc] initwithtitle:@"błąd krytyczny" message:@"wystąpił nieznany błąd przy zmienianiu zawartości w bazie danych. dla dobra twoich danych prosimy niezwłocznie wyjść z aplikacji spróbować ponownie." delegate:self cancelbuttontitle:@"ok" otherbuttontitles:nil];         [alert show];         [alert release];          nslog(@"unresolved error %@, %@", error, [error userinfo]);         abort();     }      return __fetchedresultscontroller; }      #pragma mark - fetched results controller delegate  - (void)controllerwillchangecontent:(nsfetchedresultscontroller *)controller {     [tableview beginupdates]; }  - (void)controller:(nsfetchedresultscontroller *)controller didchangesection:(id <nsfetchedresultssectioninfo>)sectioninfo            atindex:(nsuinteger)sectionindex forchangetype:(nsfetchedresultschangetype)type {     switch(type) {         case nsfetchedresultschangeinsert:             [tableview insertsections:[nsindexset indexsetwithindex:sectionindex] withrowanimation:uitableviewrowanimationfade];             break;          case nsfetchedresultschangedelete:             [tableview deletesections:[nsindexset indexsetwithindex:sectionindex] withrowanimation:uitableviewrowanimationfade];             break;     } }  - (void)controller:(nsfetchedresultscontroller *)controller didchangeobject:(id)anobject atindexpath:(nsindexpath *)indexpath      forchangetype:(nsfetchedresultschangetype)type newindexpath:(nsindexpath *)newindexpath {      if([[[controller sections] objectatindex:0] numberofobjects] == 0) {         emptysectionview.hidden = no;         uibarbuttonitem *editbtn = [[uibarbuttonitem alloc] initwithtitle:@"edytuj" style:uibarbuttonitemstylebordered target:self action:@selector(toogleediting)];         editbtn.enabled = no;         [self.navigationitem setleftbarbuttonitem:editbtn animated:no];         [editbtn release];     } else {         emptysectionview.hidden = yes;         self.navigationitem.leftbarbuttonitem.enabled = yes;     }      uitableview *table = tableview;      switch(type) {          case nsfetchedresultschangeinsert:             [table insertrowsatindexpaths:[nsarray arraywithobject:newindexpath] withrowanimation:uitableviewrowanimationfade];             break;          case nsfetchedresultschangedelete:             [table deleterowsatindexpaths:[nsarray arraywithobject:indexpath] withrowanimation:uitableviewrowanimationleft];             break;          case nsfetchedresultschangeupdate:             [self configurecell:(kstableviewcell *)[table cellforrowatindexpath:indexpath] atindexpath:indexpath];             break;          case nsfetchedresultschangemove:             [table deleterowsatindexpaths:[nsarray arraywithobject:indexpath] withrowanimation:uitableviewrowanimationfade];             [table insertrowsatindexpaths:[nsarray arraywithobject:newindexpath]withrowanimation:uitableviewrowanimationfade];             break;     } }  - (void)controllerdidchangecontent:(nsfetchedresultscontroller *)controller {     [tableview endupdates]; } 

when tap add button (faktury.m)

- (void)add:(id)sender {     fakturacreator *form = [[fakturacreator alloc] init];     form.hidesbottombarwhenpushed = yes;     form.delegate = self;     form.managedobjectcontext = self.managedobjectcontext;     [self.navigationcontroller pushviewcontroller:form animated:yes];     [form release]; } 

ok, located problem. have 'kontrahentpicker' , has nsfetchedresultscontroller too. uiviewcontroller presented modalviewcontroller. pucked kontrahent , modal dismissed , released. nsfrc's delegate still active.

i solved problem putting

self.fetchedresultscontroller.delegate = nil; 

in -dealloc method.


Comments

Popular posts from this blog

c++ - Is it possible to compile a VST on linux? -

java - Output of Eclipse is rubbish -

jquery - Confused with JSON data and normal data in Django ajax request -