我有两个实体:Department 和 DepartmentInfo。每个部门都有一个或多个 DepartmentInfo 对象。在 DepartmentInfo 中,有一个 departmentName 属性。
我想获取所有具有特定部门名称的部门对象。所以我为 Department 实体创建了一个 NSFetchRequest,并使用了这个获取请求:
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"SUBQUERY(departmentName, $s, $s.departmentName LIKE[c] %@).@count > 0", @"Marketing"];
它有效,但是:LIKE[c] 无效!我必须与确切的部门名称相匹配。如果我这样做,我将得不到匹配:
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"SUBQUERY(departmentName, $s, $s.departmentName LIKE[c] %@).@count > 0", @"Mar"];
这里有什么问题?