ind*_*gie 9 iphone cocoa-touch core-data nspredicate nsfetchrequest
我有2个实体,任务和列表.每个任务与一个名为"list"的List对象具有一对一的关系,并且与List有一个反向关系,它与Task有一个to-many关系,称为"tasks".
我正在尝试使用带有NSPredicate的获取请求来获取属于指定List的所有Task对象:
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"list=%@", theList];
[fetchRequest setPredicate:predicate];
Run Code Online (Sandbox Code Playgroud)
(其中"theParent"是对List对象的引用).但是,这不会返回任何提取的对象.如果我取出谓词,那么返回对象(所以我知道它们存在,并且通过NSLogging theList我知道它有与之关联的Task对象).
谢谢
kha*_*son 11
这可能是你谓词中的一个简单错字吗?
当我假设你真正想要的是"list ==%@"时,你有"list =%@"
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"list == %@", theList];
[fetchRequest setPredicate:predicate];
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4691 次 |
| 最近记录: |