最近看到大家对cancelPreviousPerformRequestsWithTarget不能取消带参数的
- (void)performSelector:(SEL)aSelector withObject:(id)anArgument afterDelay:(NSTimeInterval)delay;
情况,写了一点点代码调试了一下,发现如果是带参数,那取消时的参数也要一致,否则不能取消成功。
开始延迟执行:

   [self performSelector:@selector(didRuninCurrModel:) withObject:[NSNumber numberWithBool:YES] afterDelay:3.0f];

   [self performSelector:@selector(didRuninCurrModelNoArgument) withObject:nil afterDelay:3.0f];

下面是取消的方法:

   [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(didRuninCurrModel:) object:[NSNumber numberWithBool:YES]];//可以取消成功。

   [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(didRuninCurrModel:) object:[NSNumber numberWithBool:NO]];//不能取消成功。参数不匹配

   [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(didRuninCurrModel:) object:nil];//不能取消成功。参数不匹配

   [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(didRuninCurrModelNoArgument) object:nil];//可以成功取消

   [NSObject cancelPreviousPerformRequestsWithTarget:self];//可以成功取消全部。

   [[self class] cancelPreviousPerformRequestsWithTarget:self];//可以成功取消全部。

原文

http://blog.csdn.net/samuelltk/article/details/8994313