如何通过 BOOL 属性获取对象?例如,如果我有一个完成了 BOOL 属性的自定义对象,我怎样才能只获得 where 的那些completed = true
?我用的是魔法唱片
[CustomObject MR_findByAttribute:@"completed" withValue:true];
如何通过 BOOL 属性获取对象?例如,如果我有一个完成了 BOOL 属性的自定义对象,我怎样才能只获得 where 的那些completed = true
?我用的是魔法唱片
[CustomObject MR_findByAttribute:@"completed" withValue:true];
的searchValue
参数MR_findByAttribute:withValue:
必须是对对象的引用,但是true
不是对 Objective-C 对象的引用。这是一个“原始”值。您必须将其包装在一个NSValue
对象中。
此外,在 Objective-C 中,我们通常使用常量YES
和NO
作为布尔常量。
你可以通过说得到一个NSValue
包装器,所以试试这个:YES
@YES
NSArray *completedObjects = [CustomObject MR_findByAttribute:@"completed"
withValue:@YES];