ios - Result of Core Data query does not change when using a predicate to filter -
i'm building core info project in objective-c. have 3 tables names: countryarea, chargestation , plugtype. have next relations.
countryarea<-->>chargestation<<-->>plugtype
data: area1<-->>chargestation1.hasplugtype<-->type1 && -->type2 area1<-->>chargestation2.hasplugtype<-->type1 && -->type3 area1<-->>chargestation3.hasplugtype<-->type2
i'm fetching table countryarea has to-many relation chargestation, has to-many relation plugtype. i'm trying exclude chargestations illustration contain plugtype.type == 'type2' if have multiple types shouldn't excluded predicate: station3 should excluded!
[nspredicate predicatewithformat:@"subquery(stations, $c, subquery($c.hasplugtype, $t,$t.type != %@).@count).@count > 0",@"type2"];
this returns same result if wasn't using predicate.
any help?
you want exclude chargestations have plugtype.type = "type", or equivalently "include chargestations count of (plugtypes type = "type2") zero". try:
[nspredicate predicatewithformat:@"subquery(stations, $c, $c.hasplugtype.type = %@).@count = 0",@"type2"];
ios cocoa-touch core-data nspredicate
No comments:
Post a Comment