ios - mapping a subset of core-data entities as a section-key-path -


i have one-to-many relationship between:

question<<---->section 

a section has many questions. question has 1 section.

i create nsfetchedresultscontroller questions seperated sections uitableview-sections.

nsfetchrequest *fetchrequest = [nsfetchrequest fetchrequestwithentityname:@"mjuquestion"]; nssortdescriptor *sortbyname = [nssortdescriptor sortdescriptorwithkey:@"title" ascending:yes]; [fetchrequest setsortdescriptors:[nsarray arraywithobject:sortbyname]];  nsfetchedresultscontroller *afetchedresultscontroller = [[nsfetchedresultscontroller alloc]      initwithfetchrequest:fetchrequest      managedobjectcontext:context     sectionnamekeypath:@"section.title"      cachename:nil]; 

now questions seperated corresponding sections works not want.

i don't want questions of sections, want questions of specific subset of sections.

sections themselve seperated categorys:

section<<----->category 

and want questions of sections belong specific category. if nsfetchedresultscontroller sections of category add predicate like

nspredicate *predicate = [nspredicate predicatewithformat:@"category == %@", category]; [fetchrequest setpredicate:projectpredicate]; 

but since not case , want them section seperator, i'm not sure how modify nsfetchrequest properly.

so how need modify nsfetchrequest questions of specific subset of sections , these sections uitableview-section seperator?

thanks in advance.

you there. need update predicate , use key path:

nspredicate *predicate = [nspredicate predicatewithformat:@"section.category in %@", categoryarray]; 

which cause request check each question , see if section's category in array. filter down subset of categories.


Comments

Popular posts from this blog

php - SPIP: From Tag directly to an article -

jquery - isAjaxRequest always return false -

ruby on rails - In a controller spec, how to find a specific tag in the generated view? -