Latest 0.0.1
Homepage https://github.com/zhangxuchuan827/ZXCTimer
License MIT
Platforms ios 7.0
Authors

ZXClTimer

简介

ZXCTimer是一个全局的定时计时器,能够一行代码添加定时任务或者轮询任务,并且无需人为管理,控制器退出时可直接直接kill本控制器所有的任务

下载&使用

1.直接将目录下’ZXCGlobalTimer’文件夹引入工程中,并且引入NSObject+ZXCTimer.h头文件

循环任务

-(ZXCCyclesQueueItem*)addCycleTask:(dispatch_block_t)callback timeInterval:(NSTimeInterval)time;
-(ZXCCyclesQueueItem*)addCycleTask:(dispatch_block_t)callback timeInterval:(NSTimeInterval)time runCount:(NSInteger)count;
-(ZXCCyclesQueueItem*)addCycleTask:(dispatch_block_t)callback timeInterval:(NSTimeInterval)time threadMode:(ZXCThreadMode)mode;
-(ZXCCyclesQueueItem*)addCycleTask:(dispatch_block_t)callback timeInterval:(NSTimeInterval)time runCount:(NSInteger)count threadMode:(ZXCThreadMode)mode;

-(void)removeCycleTask:(ZXCCyclesQueueItem*)item;
-(void)removeAllCycleTask;

定时任务

-(ZXCTimerQueueItem*)addTimerTask:(dispatch_block_t)callback after:(NSTimeInterval)time;
-(ZXCTimerQueueItem*)addTimerTask:(dispatch_block_t)callback after:(NSTimeInterval)time threadMode:(ZXCThreadMode)mode;

-(void)removeTimerTask:(ZXCTimerQueueItem*)item;
-(void)removeAllTimerTask;

NSObject [ dealloc 时调用]

-(void)removeSelfTasks;

Demo

单例方式 可替换 self方式

------------------------------------------
[self addCycleTask:^{
        NSLog(@"【主线程】循环任务");
    } timeInterval:0.44];

[self addCycleTask:^{
        NSLog(@"【后台】循环任务");
    } timeInterval:1 threadMode:ZXCBackgroundThread];

[self addTimerTask:^{
        NSLog(@"【主线程】定时任务");
    } after:10];

[self addTimerTask:^{
        NSLog(@"【后台】定时任务");
    } after:10 threadMode:ZXCBackgroundThread];

End

若有任何问题欢迎发留言

Latest podspec

{
    "name": "ZXCTimer",
    "version": "0.0.1",
    "summary": "u4e00u4e2au7b80u5355u7684u5168u5c40u5b9au65f6/u5faau73afu4efbu52a1u7ba1u7406u5668",
    "description": "u8fd9u662fu4e00u4e2au7b80u5355u7684u5b9au65f6u3001u5faau73afu4efbu52a1u7ba1u7406u5668uff0cu80fdu591fu5168u5c40u7ba1u7406u6216u8005u662fu901au8fc7u63a7u5236u5668u6279u91cfu7ba1u7406u5b9au65f6u548cu5faau73afu4efbu52a1",
    "homepage": "https://github.com/zhangxuchuan827/ZXCTimer",
    "license": "MIT",
    "authors": {
        "zhangxuchuan": ""
    },
    "platforms": {
        "ios": "7.0"
    },
    "source": {
        "git": "https://github.com/zhangxuchuan827/ZXCTimer.git",
        "tag": "0.0.1"
    },
    "source_files": [
        "ZXCTimer",
        "ZXCTimer/**/*.{h,m}"
    ],
    "exclude_files": "ZXCTimer/Exclude",
    "public_header_files": "ZXCTimer/**/*.h"
}

Pin It on Pinterest

Share This