KYTimer
a memory safe timer.
Example
To run the example project, clone the repo, and run pod install
from the Example directory first.
Requirements
Installation
KYTimer is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'KYTimer'
How to use
使用时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];
Author
massyxf, [email protected]
License
KYTimer is available under the MIT license. See the LICENSE file for more info.