iphone - Core Data related issue -
i'm downloading content server , save in sqlite database managed coredata framework. works, have occasional crash don't understand. here crash report :
thread 5 name: dispatch queue: com.apple.root.default-priority thread 5 crashed: 0 libobjc.a.dylib 0x38eca5b6 objc_msgsend + 22 1 coredata 0x30fe354c getvaluecore + 24 2 coredata 0x30fe34fa _pfcmt_getvalue + 6 3 coredata 0x30fe346a -[nsmanagedobjectcontext(_nsinternaladditions) _retainedobjectwithid:optionalhandler:withinlinestorage:] + 34 4 coredata 0x30fe6ece -[_nsfaultingmutableset willread] + 394 5 coredata 0x30fe7518 -[_nsfaultingmutableset member:] + 84 6 corefoundation 0x3119aa50 -[nsset countforobject:] + 16 7 corefoundation 0x3123a9f4 -[nsset issubsetofset:] + 516 8 foundation 0x31b2a902 nskeyvaluewillchangebysetmutation + 406 9 foundation 0x31ac2c48 nskeyvaluewillchange + 404 10 foundation 0x31b2a760 -[nsobject(nskeyvalueobservernotification) willchangevalueforkey:withsetmutation:usingobjects:] + 260 11 coredata 0x3101e71c -[nsmanagedobject willchangevalueforkey:withsetmutation:usingobjects:] + 80 12 coredata 0x31022f26 -[nsmanagedobject(_nsinternalmethods) _excludeobject:frompropertywithkey:andindex:] + 626 13 coredata 0x31023df4 -[nsmanagedobject(_nsinternalmethods) _maintaininverserelationship:forproperty:olddestination:newdestination:] + 228 14 coredata 0x31024622 -[nsmanagedobject(_nsinternalmethods) _didchangevalue:forrelationship:named:withinverse:] + 1286 15 coredata 0x3102dc3e -[nsmanagedobjectcontext observevalueforkeypath:ofobject:change:context:] + 318 16 foundation 0x31ac36b4 nskeyvaluenotifyobserver + 268 17 foundation 0x31ac330e nskeyvaluedidchange + 330 18 foundation 0x31a9d6ce -[nsobject(nskeyvalueobservernotification) didchangevalueforkey:] + 90 19 coredata 0x3101e234 _pf_managedobject_didchangevalueforkeyindex + 100 20 coredata 0x310287b2 _sharedimpl_setvfk_core + 222 21 instabay 0x000bf3a0 -[adgetmemberstuffswsproxy processdata:] (adgetmemberstuffswsproxy.m:101) 22 instabay 0x000a7328 -[ibabstractwsproxy didreceivedata:] (ibabstractwsproxy.m:437) 23 corefoundation 0x312389c0 __invoking___ + 64 24 corefoundation 0x3118ffe6 -[nsinvocation invoke] + 282 25 foundation 0x31b38b60 -[nsinvocationoperation main] + 108 26 foundation 0x31ac25bc -[__nsoperationinternal start] + 836 27 foundation 0x31b3abde __block_global_6 + 98 28 libdispatch.dylib 0x392e711c _dispatch_call_block_and_release + 8 29 libdispatch.dylib 0x392f5254 _dispatch_root_queue_drain + 256 30 libdispatch.dylib 0x392f53b4 _dispatch_worker_thread2 + 80 31 libsystem_c.dylib 0x3931ba0e _pthread_wqthread + 358 32 libsystem_c.dylib 0x3931b8a0 start_wqthread + 4
and method crash occurs :
- (id) processdata:(id)thedata { nsmanagedobjectcontext *moc = self.backgroundmoc; // fetch members nsdictionary *existingmembersmap = [[ibwsutils fetchexistingmemberslistby:@"memberid" inmanagedobjectcontext:moc] retain]; // fetch existing ads (we need id build our cache mapping) nsdictionary *existingadsmap = [[ibwsutils fetchexistingadslistinmanagedobjectcontext:moc] retain]; ibmember *member = (ibmember *)[moc objectwithid:self.memberobjectid]; // purge existing results, otherwise leave , append bottom if (! self.shouldappendresults) { if (member.stuffs != nil) { [member removestuffs:member.stuffs]; } // member.stuffs = nil; } // sets total number of ads member.stuffscount = [nsnumber numberwithinteger:[thedata integerforkey:@"quantity"]]; nsarray *ads = [thedata objectforkey:@"ad"]; (nsdictionary *addict in ads) { if ([addict iskindofclass:[nsnull class]]) { continue; } // @autoreleasepool { nsstring *currentadid = [addict objectforkey:@"id"]; // existing ad copy ibad *currentad = [existingadsmap objectforkey:currentadid]; if (!currentad) { // otherwise, create new ad instance currentad = [nsentitydescription insertnewobjectforentityforname:@"ad" inmanagedobjectcontext:moc]; currentad.adid = currentadid; currentad.creationdate = [nsdate datewithtimeintervalsince1970:[[addict nonnullvalueforkeypath:@"createdat.sec"] floatvalue]]; } currentad.addescription = [addict objectforkey:@"description"]; // if member instance doesn't exist, create new 1 nsstring *memberid = [addict nonnullvalueforkeypath:@"seller.memberid"]; ibmember *existingmember = [existingmembersmap objectforkey:memberid]; if (!existingmember) { existingmember = [nsentitydescription insertnewobjectforentityforname:@"member" inmanagedobjectcontext:moc]; existingmember.memberid = memberid; existingmember.username = [addict nonnullvalueforkeypath:@"seller.membername"]; } **// line below line 101 causes crash currentad.member = existingmember;** @try { currentad.mediauri = [[[addict objectforkey:@"media"] objectatindex:0] objectforkey:@"uri"]; } @catch (nsexception *exception) { currentad.mediauri = nil; } ibwanted *wants = currentad.wants; if (!wants) { // otherwise, create new ad instance wants = [nsentitydescription insertnewobjectforentityforname:@"wanted" inmanagedobjectcontext:moc]; currentad.wants = wants; } wants.count = [nsnumber numberwithinteger:[addict integerforkey:@"followwanted"]]; [member addstuffsobject:currentad]; } } // save operation [self savebackgroundmanagedobjectcontext]; [existingadsmap release]; [existingmembersmap release]; return nil; }
i don't know did wrong.
** edit ** bug occurs on device. no problem simulator.
Comments
Post a Comment