KYTimer
一个内存安全的定时器。
示例
要运行示例项目,请克隆仓库,然后首先从Example目录运行pod install
。
需求
安装
KYTimer可通过CocoaPods获取。要安装,只需在Podfile中添加以下行即可:
pod 'KYTimer'
如何使用
使用KYTimer时,需要对其进行强引用,否则会自动释放。
<方案1
_timer = [KYProxyTimer timerWithTimeInterval:1 target:self selector:@selector(timerProxyRun) userInfo:nil repeat:YES];
[_timer addTimerToRunloop:[NSRunLoop currentRunLoop] mode:NSRunLoopCommonModes];
<方案2
_gcdTimer = [KYGCDTimer timerStartAfter:10 timeInterval:1 action:^{
NSLog(@"基于gcdtimer的定时器");
} queue:dispatch_get_main_queue() repeat:YES];
[_gcdTimer fire];
<作者
massyxf, [email protected]
<许可
KYTimer依MIT许可证提供。有关更多信息,请参阅LICENSE文件。