iam_lmk 2014-05-13 06:08 采纳率: 0%
浏览 5394

ios block作为参数时,自身的参数是谁传递的

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这个三个参数谁谁个他传递的呢?

  • 写回答

2条回答 默认 最新

  • zhouleizhao 2014-06-04 08:49
    关注

    在什么地方使用的时候,传递就可以了啊!
    BOOL isContain = test(@"A",2,NO);

    评论

报告相同问题?