Selector改写成Block

+ (NSTimer *)scheduledTimerWithTimeInterval:(NSTimeInterval)interval block:(void (^)())block repeats:(BOOL)repeats {

return [self scheduledTimerWithTimeInterval:interval target:self selector:@selector(blockInvoke:) userInfo:[block copy] repeats:repeats];

}

+ (void)blockInvoke:(NSTimer *)timer {

void (^ block)() = timer.userInfo;

if (block) {

block();

}

}

你可能感兴趣的:(Selector改写成Block)