qxuewei / XWTimer

GCD Timer

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

XWTimer

A Simple GCD Timer with Objective-C.

CocoaPod

pod 'XWTimer'

How to use?

target-selector

self.timer = [XWTimer timerWithTimeInterval:1.0 target:self selector:@selector(timerMethod) repeats:YES];

- (void)timerMethod
{
    /// do somethings
}

block

__weak typeof(self) weakSelf = self;
self.timer =[XWTimer timerWithTimeInterval:1.0 repeats:YES block:^(XWTimer * _Nonnull timer) {
    __strong typeof(weakSelf) strongSelf = weakSelf;
    /// do somethings
}];

Start

[self.timer fire];

Pause

[self.timer pause];

Invalidate

[self.timer invalidate];

About

GCD Timer

License:MIT License


Languages

Language:Objective-C 96.9%Language:Ruby 3.1%