ios - Core Data Fetch Based on Entity Relationship -


i'm trying call core data, associated specific category. app this:

  • click category
  • click sub-category question
  • view question

i have views set up, , had partner set core data, running issue regardless of category pick, still loads questions.

i pass category selection category list view, i'm not sure it, , how should calling core data. have (again, returns questions): nsentitydescription *entity = [nsentitydescription entityforname:@"question" inmanagedobjectcontext:[appdelegate managedobjectcontext]];

the categories , questions have inverse relationship in data model. should using predicates, nsrelationshipdescription, or else?

can not access nsset of questions? i.e. category.questions

to answer question predicate:

if looking find questions specific category need specify category in nspredicate

something like:

(nsarray *)findquestionsforcategory:(category *)category { nsfetchrequest *fetch = [[nsfetchrequest alloc] init]; nsentitydescription *entity = [nsentitydescription entityforname:@"question" inmanagedobjectcontext:[appdelegate managedobjectcontext]]; [fetch setpredicate:[nspredicate predicatewithformat:@"question.category == %@", category]];  ... execute fetch request, handle possible errors ...  } 

Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

html - Unable to style the color of bullets in a list -

c# - must be a non-abstract type with a public parameterless constructor in redis -