我有三个实体:EntityA,EntityB和EntityC与多对多关系连接.
请参阅架构了解详情:
替代文字http://img706.imageshack.us/img706/9974/screenshot20091220at124.png
为了获取依赖于EntityB.name的EntityA的所有实例,我使用这样的谓词:
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"ANY EntityB.name like 'SomeName'"];
Run Code Online (Sandbox Code Playgroud)
获取依赖于EntityC.name的所有EntityA实例应该是什么谓词?我尝试过查询@"ANY EntityB.entitiesC.name like 'SomeName'"但得到异常"multiple to-many keys not allowed here".
最好的祝福,
胜利者
我有一个NSArrayController,companiesController绑定到顶级Core Data实体,Companies.
A Company有很多Department,Department有很多Employee; 这些由1对多关系表示,departments和employees.
基于我认为的属性salary,Employee我可以动态地根据UI调用的方法中的工资进行过滤:
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"ANY departments.employees.salary < %@", [NSNumber numberWithInt:23000]];
[companiesController setFilterPredicate:predicate];
Run Code Online (Sandbox Code Playgroud)
唉,这给了我错误:-[NSCFSet compare:]: unrecognized selector sent to instance.