NSTimers 防抖的 Objective-C 库
将此放在您的 Podfile 中并使用它
pod 'LVDebounce'
这是一个非常简单的 API,旨在尽可能地反映 NSTimer API。
以下是一个示例
#import "LVDebounce.h"
- (void)helloWorld {
NSLog(@"Hello, World!"); // Will only run once
}
- (void)applicationDidFinishLaunching {
for (int i = 0; i < 10; i++) {
[LVDebounce fireAfter:1.0 target:self selector:@selector(helloWorld) userInfo:nil];
}
}
就是这样。