Latest 1.1.0
Homepage https://github.com/zhooleen/TimerManager
License MIT
Platforms ios 7.0
Authors
  1. Automatically cancel the timer when the timer holder dealloc
  2. Automatically cancel all timer when app did enter background. Resume them manually if necessarily.
  3. Also, Cancel the timer manually if required.

Timers

The protocol id has four instance methods as follows:

[resume] : start or resume a timer

[suspend]: suspend the timer

[cancel] : stop the timer

[isRunning]

  1. Normal timers

    [RTTimerManager timerWithInterval:repeated:queue:block:] execute the callback in a specified queue

    [RTTimerManager timerWithInterval:repeated:block:] execute the callback in main thread

  2. Countdown timer

    [RTTimerManager countdownTimerWithIdentifier:duration:interval:block]

  3. Display Link

    [RTTimerManager displayLinkWithFrameInterval:block]

Usage

/**
Get the timer
*/
__weak typeof(self) werakself = self;
id<RTTimer> timer = [RTTimerManager timerWithInterval:0.1f repeated:YES block:^{
    __strong typeof(weakself) this = weakself;
    //Do your work in the block using this instead of self if necessarily.
}];

/**
Hold it
*/
self.timer = timer;

/**
Resume
*/
[self.timer resume];

/**
Cancel
*/
[self.timer cancel]; //awake it again by `[self.timer resume]`;
/**
OR
*/
self.timer = nil; //cancel forever

WARNINGS

Don’t let block retain a strong reference to self

Latest podspec

{
    "name": "TimerManager",
    "version": "1.1.0",
    "summary": "Automatically & manualy manage the timer life cycle.",
    "description": "Automatically & manualy manage the timer life cycle. nIt can be cancelled when the timer dealloc.",
    "homepage": "https://github.com/zhooleen/TimerManager",
    "license": "MIT",
    "authors": {
        "lzhu": "[email protected]"
    },
    "platforms": {
        "ios": "7.0"
    },
    "source": {
        "git": "https://github.com/zhooleen/TimerManager.git",
        "tag": "1.1.0"
    },
    "source_files": [
        "Classes",
        "Classes/**/*.{h,m}"
    ],
    "exclude_files": "Classes/Exclude"
}

Pin It on Pinterest

Share This