objective-c 定时运行和取消

[self performSelector:@selector(handleKeyPressAndHold:)
                 withObject:nil afterDelay:0.5];

0.5秒之后运行handleKeyPressAndHold函数

如果0.5内要取消运行,
[NSObject cancelPreviousPerformRequestsWithTarget:self 
                                             selector:@selector(handleKeyPressAndHold:)
                                               object:nil];

posted on 2012-09-12 15:16  barani  阅读(321)  评论(0编辑  收藏  举报

导航