ios - Core data doesn't display data / nil relationships -


i have ios application uses core data. have quite complex model (10+ entities) , working well... of time. need in tracking down root cause of couple of issues or general pointers causing issues , for.

a couple of end users experiencing issues. there 2 issues both relating core data. both seem appear after while (hours/days after first use).

the first retrieving list of call objects array generate json them. code works fine, 1 or 2 users after while start getting error. call entity has relationship callstatus object - relationship called statusforcall. there no way user set relationship nil. relationship defineltly set when call entity generated. status set , happy after initial save user has checked this). 1 times call objects statusforcall relationship returning nil.

installing app on top seems fix issue (the data doesn't changed doing this, relationship magiacally works again).

the second issues have different. retrieving list of call objects through nsfetchedresultscontroller table view. has simple filter applied. table view blank. if apply original filter , additional filter data returned. initial filter closeddate not nil. leaves tableview blank, though there matching records. if change filter closeddate not nil , scheduleddate not nil returns data tableview thought filter same original, added condition.

again issue couple of users. doesn't happen straight waway , can take hours/days start.

strangely tableview issue seems solve again after while.

i have seen suggestions behaviour being casued caching, have specified nil cachename fetch requests.

the fact 99% sure data correct bit don't understand.

the first issue stausforcall being nil - understand cd might not give data until access property of relationship., bbut doing this. line errors is:

[dict setobject:acall.statsuforcall.statusid forkey:@"statusid"]; 

so accessing property.

as relationship cannot set nil user , there no code alter relationship once call object has been created.

the fact happens after period of time confuses me.

the table view not giving me data bit random. happened on 2 different view controllers accessing different objects in cd. without changing code or application user reported started working again after few hours or not working.

can cd store corrupt? can caching issue? how can test underlying data ok?

the biggest issue when users report issue - if add debug code build , them overwrite application issues disappear instantly. code , data not change, have add debug alerts.

again due core data thinking it's migrating data , "fixing" whatever issue has manifested?

i'm quite confused (as can tell!!)

code fetch request - pleas note there action button 2 choices user - "open jobs" works 99.999999% of time stops user after undefined period of time. when first filter not working second 1 still does.

[self changetitle]; nsfetchrequest *request=[nsfetchrequest fetchrequestwithentityname:@"call"]; nsstring *sectionkeypathname=nil;  nsstring *searchpre=self.searchbar.text;  // self.showindex = yes; if ([self.mode isequaltostring:@"open jobs"]) {         request.predicate = [nspredicate predicatewithformat:@" closeddate = nil , assignedtocall==yes"];       if ([self.searchbar.text length]>0)     {         nspredicate * newcondition = [nspredicate predicatewithformat:@"(shortaddress contains[cd] %@ or address contains[cd] %@ or lettingarea contains[cd] %@  or postcode contains[cd] %@ or woref contains[cd] %@)",searchpre,searchpre,searchpre,searchpre,searchpre];         nspredicate * newpredicate = [nscompoundpredicate andpredicatewithsubpredicates:[nsarray arraywithobjects:request.predicate, newcondition, nil]];         request.predicate = newpredicate;     }        nssortdescriptor *sortdescriptor = [[nssortdescriptor alloc] initwithkey:@"hasappointmentfororderby" ascending:no ];      nssortdescriptor *sortdescriptor2 = [[nssortdescriptor alloc] initwithkey:@"datescheduled" ascending:yes ];      nssortdescriptor *sortdescriptor3 = [[nssortdescriptor alloc] initwithkey:@"scheduledtime" ascending:yes selector:@selector(localizedcaseinsensitivecompare:)];     nssortdescriptor *sortdescriptor4 = [[nssortdescriptor alloc] initwithkey:@"datedue" ascending:yes ];      nsarray *sortdescriptors = [[nsarray alloc] initwithobjects:sortdescriptor,sortdescriptor2,sortdescriptor3,sortdescriptor4, nil];     [request setsortdescriptors:sortdescriptors];      sectionkeypathname=@"sectionheadersortscheduledornot"; } if ([self.mode isequaltostring:@"today's jobs (only)"]) {       nsdatecomponents* comps = [[nscalendar currentcalendar] components:nsyearcalendarunit|nsmonthcalendarunit|nsdaycalendarunit fromdate:[nsdate date]];     nsdate* todaynotime = [[nscalendar currentcalendar] datefromcomponents:comps];       request.predicate = [nspredicate predicatewithformat:@"(datedue = %@  or datescheduled = %@)  , closeddate = nil , assignedtocall==yes",todaynotime,todaynotime];       if ([self.searchbar.text length]>0)     {         nspredicate * newcondition = [nspredicate predicatewithformat:@"(shortaddress contains[cd] %@ or address contains[cd] %@ or lettingarea contains[cd] %@  or postcode contains[cd] %@ or woref contains[cd] %@)",searchpre,searchpre,searchpre,searchpre,searchpre];         nspredicate * newpredicate = [nscompoundpredicate andpredicatewithsubpredicates:[nsarray arraywithobjects:request.predicate, newcondition, nil]];         request.predicate = newpredicate;     }       nssortdescriptor *sortdescriptor = [[nssortdescriptor alloc] initwithkey:@"shortaddress" ascending:yes selector:@selector(localizedcaseinsensitivecompare:)];      nsarray *sortdescriptors = [[nsarray alloc] initwithobjects:sortdescriptor, nil];     [request setsortdescriptors:sortdescriptors];      sectionkeypathname=@"lettingarea"; }  self.currentfilter= request.predicate;   [self.managedobjectcontext performblockandwait:^{     self.fetchedresultscontroller =[[nsfetchedresultscontroller alloc ] initwithfetchrequest:request managedobjectcontext:self.managedobjectcontext sectionnamekeypath:sectionkeypathname cachename:nil]; }]; 

check

  • the cache name of fetched results controller. recommend setting nil.
  • the predicate checking null. maybe should post code.

Comments

Popular posts from this blog

ruby on rails - RuntimeError: Circular dependency detected while autoloading constant - ActiveAdmin.register Role -

c++ - OpenMP unpredictable overhead -

javascript - Wordpress slider, not displayed 100% width -