【发布时间】:2013-06-27 23:03:51
【问题描述】:
我想过滤 NSSet:
NSSet* contents = [self.content objectsPassingTest:^(id obj, BOOL* stop){
NSNumber* chapterNo = ((LTContent*)obj).chapterNo;
return [chapterNo integerValue] < 0;
}];
但是这段代码会引发错误:incompatible block pointer types sending 'int (^)(id, BOOL *)' to parameter of type 'BOOL (^)(id, BOOL *)
如果我更改代码:
NSSet* contents = [self.content objectsPassingTest:^(id obj, BOOL* stop){
NSNumber* chapterNo = ((LTContent*)obj).chapterNo;
BOOL a = [chapterNo integerValue] < 0;
return a;
}];
效果很好。但我不想使用奇数行。第一个 sn-p 有什么问题?
【问题讨论】:
标签: ios objective-c objective-c-blocks nsset