【发布时间】:2014-12-29 06:32:24
【问题描述】:
我正在用 Objective-C 构建一个 Core Data 项目。我有三个带有名称的表:CountryArea、ChargeStation 和 PlugType。它们有以下关系。
CountryArea>ChargeStation>PlugType
Data:
area1<-->>chargestation1.hasPlugType<-->type1 && -->type2
area1<-->>chargestation2.hasPlugType<-->type1 && -->type3
area1<-->>chargestation3.hasPlugType<-->type2
我正在从表 CountryArea 中获取,该表与 ChargeStation 具有一对多关系,而 ChargeStation 与 PlugType 具有一对多关系。我正在尝试排除所有例如包含 PlugType.type == 'type2' 但如果它们有多种类型的 ChargeStations,则不应使用此谓词排除它们: 只有 station3 应该被排除!
[NSPredicate predicateWithFormat:@"SUBQUERY(stations, $C, SUBQUERY($C.hasPlugType, $T,$T.type != %@).@count).@count > 0",@"type2"];
这会返回与我没有使用谓词相同的结果。
有什么帮助吗?
【问题讨论】:
标签: ios cocoa-touch core-data nspredicate