NSArray *array = [NSArray arrayWithObjects: @"A", @"B", @"C", @"A", @"B", @"Z",@"G", @"are", @"Q", nil];
NSSet *filterSet = [NSSet setWithObjects: @"A", @"Z", @"Q", nil];
BOOL (^test)(id obj, NSUInteger idx, BOOL *stop);
test = ^ (id obj, NSUInteger idx, BOOL *stop) {
if (idx < 5) {
if ([filterSet containsObject: obj]) {
return YES;
}
}
return NO;
};
当block函数作为参数时,自身的参数是谁给它传递的呢?例如上面代码中的test = ^ (id obj, NSUInteger idx, BOOL *stop),obj,idx,stop这个三个参数谁谁个他传递的呢?
在什么地方使用的时候,传递就可以了啊!
BOOL isContain = test(@"A",2,NO);
这哪里是block 做为参数啊,这是带参数的block