Latest 0.0.2
Homepage https://github.com/alexiiio/LDGCDTimer
License MIT
Platforms ios 7.0, requires ARC
Frameworks UIKit
Authors

基于GCD的简单timer工具类。真的很简单,并不是为了学习怎么上传代码到Cocopods~ [一脸正经]

Usage

pod ‘LDGCDTimer’

代码

使用单例时,不需要强引用timer。 循环事件如果要回到主线程,需自行处理。

    [LDGCDTimer runShareTimerWithInteval:1 afterDelay:2 action:^{
        //do something
        dispatch_async(dispatch_get_main_queue(), ^{
            //do some UI operation
        });
    }];

或者,限定循环次数:

    LDGCDTimer *timer = [LDGCDTimer shareTimer];
    [timer runTimerWithInteval:0.7 afterDelay:0 circleCount:10 action:^{
    // do something

    }];

或者,执行到某个个日期

    LDGCDTimer *timer = [LDGCDTimer shareTimer];
    [timer runTimerWithInteval:1 afterDelay:0 untilDate:[NSDate dateWithTimeIntervalSinceNow:30] action:^{
        // do something
    }];

或者使用非单例对象,可同时创建多个timer。但必须强引用timer,防止被提前释放。

    self.timer = [[LDGCDTimer alloc]init];
    [self.timer runTimerWithInteval:1 afterDelay:0 untilDate:[NSDate dateWithTimeIntervalSinceNow:30] action:^{
        // do something
    }];

Latest podspec

{
    "name": "LDGCDTimer",
    "version": "0.0.2",
    "license": "MIT",
    "summary": "u4e00u4e2aGCD timeru7b80u5355u5de5u5177u7c7b",
    "description": "u4e00u4e2aGCD timeru7b80u5355u5de5u5177u7c7bu3002u652fu6301u5faau73afu6b21u6570uff0cu5faau73afu5230u67d0u65e5uff0cu6682u505cu548cu6062u590du3002",
    "homepage": "https://github.com/alexiiio/LDGCDTimer",
    "authors": {
        "alexiiio": "[email protected]"
    },
    "source": {
        "git": "https://github.com/alexiiio/LDGCDTimer.git",
        "tag": "v0.0.2"
    },
    "requires_arc": true,
    "platforms": {
        "ios": "7.0"
    },
    "source_files": "LDGCDTimer/LDGCDTimer/",
    "frameworks": "UIKit"
}

Pin It on Pinterest

Share This