1. 程式人生 > >第32月第12天 block stop

第32月第12天 block stop

break sel nbsp ble arr integer span object ear

1.

- (NSMutableArray *)filterUsingBlock:(BOOL (^)(id obj, NSUInteger idx, BOOL *stop))block
{
    if (!block) {
        return [self mutableCopy];
    }
    
    NSMutableArray *result = [NSMutableArray array];
    NSUInteger idx = 0;
    BOOL stop = NO;
    
    for (id obj in self) {
        
if (block(obj, idx, &stop)) { [result addObject:obj]; if (stop) { break; } } idx++; } return result; }

第32月第12天 block stop