ios - Core Data:Fetch rlelationships or Fetch Main Entity -
i have entity a has to-many relationships entity b.
entity -->> entity b i need refer count of to-many relationship, @ more 1 screen. further, can remove , add reference entity b entity a multiple times.
now, question : best way refer relationship count?
what observed:?
1] can make count attribute in entity a , increment/decrement according relationship count , fetch attribute on screens need.
2] can count count property of nsset(of relationships), way not have fetch entitya. can do,
nsset *set = entitya.entitiesb; nsinteger count = set.count; this way fetch happens not have create fetch request again , again entitya.
appreciate help.
you don't have fetch anything, can create fetch request suitable predicate , use countforfetchrequest:error: count. create fetch request template (setfetchrequesttemplate:forname:) , use fetchrequestfromtemplatewithname:substitutionvariables: when need use it.
Comments
Post a Comment