i have exc_bad_access killing me. cannot see coming from.
arc code. symptomrating managed object, of course:
__block dplsymptomrating *rating; self.editmoc = [[nsmanagedobjectcontext alloc] initwithconcurrencytype:nsprivatequeueconcurrencytype]; // retained: strong nsmanagedobjectcontext *moc = self.editmoc; //editsymptom.managedobjectcontext; [moc performblockandwait:^{ nserror __autoreleasing *error = nil; moc.parentcontext = dplpersonalhxdatastore.shared.managedobjectcontext; rating = [nsentitydescription insertnewobjectforentityforname:@"symptomrating" inmanagedobjectcontext:moc]; [moc assignobject:rating topersistentstore:[nspersistentstore mr_defaultpersistentstore]]; rating.ratingcode = @101; rating.symptomcode = 1; rating.displayname = @"debug"; nsassert(rating!=nil, @"cannot edit nil rating"); nsassert(rating.managedobjectcontext==moc, @""); nslog(@"validates insert: %@", [rating validateforinsert:&error]?@"true":@"false"); nsassert(error==nil,@""); nslog(@"inserted objects: %@", moc.insertedobjects); // 1 object, above nslog(@"updated objects: %@", moc.updatedobjects); // empty nslog(@"deleted objects: %@", moc.deletedobjects); // empty [moc save:&error]; // -->fail: exc_bad_access (code=2, address=0x2) nslog(@"can here?"); // nope nsassert(error==nil, @""); }]; this crashes same error whether concurrency type main or private, , or without -performblock: or -performblockandwait:
i have nszombieenabled (i think -- don't know how verify if it's working).
backtrace:
frame #0: 0x019c0098 libobjc.a.dylib`objc_msgsend + 12 frame #1: 0x0087e5e0 coredata`_pfobjectidfasthash64 + 96 frame #2: 0x01fb48d0 corefoundation`__cfdictionaryhashkey + 32 frame #3: 0x01f0a114 corefoundation`cfbasichashfindbucket + 1572 frame #4: 0x01f09ad5 corefoundation`cfdictionarygetvalue + 133 frame #5: 0x0088cde8 coredata`-[nspersistentstorecache incrementrefcountforobjectid:] + 40 frame #6: 0x0088cd74 coredata`-[nssqlcore managedobjectcontextdidregisterobjectswithids:] + 228 frame #7: 0x009528aa coredata`-[nspersistentstorecoordinator(_nsinternalmethods) _informaffectedstoresofinterestbychildcontextinobjectswithobjectids:withselector:] + 122 frame #8: 0x0088cc7f coredata`-[nspersistentstorecoordinator(_nsinternalmethods) managedobjectcontextdidregisterobjectswithids:] + 47 frame #9: 0x008bd9e9 coredata`__-[nsmanagedobjectcontext(_nestedcontextsupport) managedobjectcontextdidregisterobjectswithids:]_block_invoke_1 + 73 frame #10: 0x008bce41 coredata`internalblocktonsmanagedobjectcontextperform + 17 frame #11: 0x01de5953 libdispatch.dylib`_dispatch_barrier_sync_f_invoke + 61 frame #12: 0x01de5e00 libdispatch.dylib`dispatch_barrier_sync_f + 62 frame #13: 0x008bcde5 coredata`_perform + 117 frame #14: 0x008bd999 coredata`-[nsmanagedobjectcontext(_nestedcontextsupport) managedobjectcontextdidregisterobjectswithids:] + 73 frame #15: 0x008bd9e9 coredata`__-[nsmanagedobjectcontext(_nestedcontextsupport) managedobjectcontextdidregisterobjectswithids:]_block_invoke_1 + 73 frame #16: 0x008bcdc4 coredata`_perform + 84 frame #17: 0x008bd999 coredata`-[nsmanagedobjectcontext(_nestedcontextsupport) managedobjectcontextdidregisterobjectswithids:] + 73 frame #18: 0x008ac672 coredata`-[nsmanagedobjectcontext(_nsinternaladditions) _informparentstore:ofinterestinobjects:] + 274 frame #19: 0x008991e8 coredata`-[nsmanagedobjectcontext save:] + 536 frame #20: 0x000a06fc myapp`__53-[dplnotesviewcontroller editratingforindexpath:new:]_block_invoke(.block_descriptor=0xbfffe260) + 1836 @ dplnotesviewcontroller.m:270 frame #21: 0x008bcaf3 coredata`developersubmittedblocktonsmanagedobjectcontextperform + 99 frame #22: 0x01de5953 libdispatch.dylib`_dispatch_barrier_sync_f_invoke + 61 frame #23: 0x01de5e00 libdispatch.dylib`dispatch_barrier_sync_f + 62 frame #24: 0x008bca48 coredata`-[nsmanagedobjectcontext performblockandwait:] + 136 frame #25: 0x0009fe61 myapp`-[dplnotesviewcontroller editratingforindexpath:new:](self=0x0a367eb0, _cmd=0x0010fb59, indexpath=0x083f9200, new='\x01') + 465 @ dplnotesviewcontroller.m:251 frame #26: 0x0009f786 myapp`-[dplnotesviewcontroller tableview:didselectrowatindexpath:](self=0x0a367eb0, _cmd=0x02ba0ff6, tableview=0x08c69a00, indexpath=0x083f9200) + 150 @ dplnotesviewcontroller.m:195 frame #27: 0x00bad71d uikit`-[uitableview _selectrowatindexpath:animated:scrollposition:notifydelegate:] + 1164 frame #28: 0x00bad952 uikit`-[uitableview _userselectrowatpendingselectionindexpath:] + 201 frame #29: 0x0143586d foundation`__nsfiredelayedperform + 389 frame #30: 0x01fc6966 corefoundation`__cfrunloop_is_calling_out_to_a_timer_callback_function__ + 22 frame #31: 0x01fc6407 corefoundation`__cfrunloopdotimer + 551 frame #32: 0x01f297c0 corefoundation`__cfrunlooprun + 1888 frame #33: 0x01f28db4 corefoundation`cfrunlooprunspecific + 212 frame #34: 0x01f28ccb corefoundation`cfrunloopruninmode + 123 frame #35: 0x021ac879 graphicsservices`gseventrunmodal + 207 frame #36: 0x021ac93e graphicsservices`gseventrun + 114 frame #37: 0x00b1da9b uikit`uiapplicationmain + 1175 what else can try? help!
the problem turns out ios 5 bug parent contexts apparently cannot see children's new relationships. forcing core data obtain permanent object ids before trying save fixes problem, so:
[moc obtainpermanentidsforobjects:@[rating] error:&error]; [moc save:&error]; // --> works
Comments
Post a Comment