i have 2 many-to-many related entities, customer
, city
, nsmanagedobject subclasses generated them. have relationship customer
city
called cities
. in city
there property called city
. trying fetch entity customer
simple fetchresultscontroller
:
-(nsfetchedresultscontroller *) fetchedresultscontroller { if (_fetchedresultscontroller != nil) { return _fetchedresultscontroller; } self.managedobjectcontext = [[ptdatamanager sharedmanager] managedobjectcontext]; nsfetchrequest *fetchrequest = [[nsfetchrequest alloc] init]; nsentitydescription *entity = [nsentitydescription entityforname:@"customer" inmanagedobjectcontext:[self managedobjectcontext]]; [fetchrequest setentity:entity]; _fetchedresultscontroller = [[nsfetchedresultscontroller alloc] initwithfetchrequest:fetchrequest managedobjectcontext:self.managedobjectcontext sectionnamekeypath:nil cachename:nil]; _fetchedresultscontroller.delegate = self; return _fetchedresultscontroller; }
as result retrieving fine except cities
property ((null) value) predicate
@"cities.name contains[cd] %@"
in customer
subclass can use method:
-(city *)city { return (cdcities *)[[ptdatafetchhelper sharedinstance] entityforname:@"city" withserverid:self.city_server_id incontext:[self managedobjectcontext]]; }
and retrieving city
-values fine, way slows down ui (displaying data in tableview).
so, questions:
- if perform basic fetch this, retrieve values of specified entity only, or values related entities too?
- if need additional predicate, how can modify fetch
city
propertiescity
entity?
a fetch request fetches 1 entity type. if fetch customer
, customer
s. can traverse core data relationships without doing additional fetch requests. ask customer
instance value of cities
attribute. 0 or more city
instances, , can ask each 1 of city
attribute.
i'm not sure you're getting @ @"cities.city [cd]"
. that's not predicate. part of predicate, doesn't match city
attribute against anything. it's 1 side of equation.
Comments
Post a Comment