ios - NSFetchedResultsController Not Caching correctly -



ios - NSFetchedResultsController Not Caching correctly -

i having weird issue. have setup 2 nsfetchedresultscontrollers

like so

// setup fetched results controller [self setfilescontroller:[pcsdataaccessor filesindirectroy:@"" forworkgroup:[nsnumber numberwithinteger:0] withcontext:[pcsmanagedobjectcontext context]]]; [self setworkgroupscontroller:[pcsdataaccessor memberworkgroupsfetchedresultscontrollerwithcontext:[pcsmanagedobjectcontext context]]]; #pragma mark - fetched results controller methods + (nsfetchedresultscontroller *)memberworkgroupsfetchedresultscontrollerwithcontext:(pcsmanagedobjectcontext *)context { // create fetch request nsentitydescription * entitydescription = [nsentitydescription entityforname:@"pcsmanagedworkgroup" inmanagedobjectcontext:context]; nsfetchrequest * request = [[nsfetchrequest alloc] init]; [request setentity:entitydescription]; // set workgroupid find nspredicate *predicate = [nspredicate predicatewithformat:@"(workgroupid != 0)"]; [request setpredicate:predicate]; // set sort options nssortdescriptor * sort = [[nssortdescriptor alloc] initwithkey:@"name" ascending:no]; [request setsortdescriptors:[nsarray arraywithobject:sort]]; // create feched results controller nsfetchedresultscontroller * resultscontroller = [[nsfetchedresultscontroller alloc] initwithfetchrequest:request managedobjectcontext:context sectionnamekeypath:nil cachename:@"workgroups"]; // homecoming results homecoming resultscontroller; } + (nsfetchedresultscontroller *)filesindirectroy:(nsstring *)directorypath forworkgroup:(nsnumber *)workgroupid withcontext:(pcsmanagedobjectcontext *)context { // create fetch request nsentitydescription * entitydescription = [nsentitydescription entityforname:@"pcsmanagedfile" inmanagedobjectcontext:context]; nsfetchrequest * request = [[nsfetchrequest alloc] init]; [request setentity:entitydescription]; // set file find nsstring * regexstring = [[nsstring alloc] initwithformat:@"^%@[^/]+$",directorypath]; nspredicate *predicate = [nspredicate predicatewithformat:@"workgroup.workgroupid == %@ && name matches %@",workgroupid,regexstring]; [request setpredicate:predicate]; // set sort options nssortdescriptor * sort = [[nssortdescriptor alloc] initwithkey:@"name" ascending:no]; [request setsortdescriptors:[nsarray arraywithobject:sort]]; // create feched results controller nsfetchedresultscontroller * resultscontroller = [[nsfetchedresultscontroller alloc] initwithfetchrequest:request managedobjectcontext:context sectionnamekeypath:nil cachename:[nsstring stringwithformat:@"%@/%@",workgroupid,directorypath]]; // homecoming results homecoming resultscontroller; }

when add together things core info homecoming in request show expect. issue having when terminate app , bring both fetched requests controllers have no data. can query core info , there.

i have been able solve problem passing in nil cache name.

i able utilize cache since have multiple fetched results controllers , have big info sets in them.

ios caching nsfetchedresultscontrolle

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -