Coder Social home page Coder Social logo

zygcdtimer's Introduction

ZYGCDTimer

Version License Platform

ZYGCDTimer 主要用于替代 NSTimer,不会强持有 target,基于 MSWeakTimer 进行修改的,本质上是个 GCD 定时器。

Features

  • 弱引用 target
  • target 销毁之后,自动调用 invalidate
  • 支持 block 创建定时器
  • 支持设置 GCD queue
  • 支持暂停定时器

Example

下载 demo 直接运行即可

Requirements

  • iOS 8.0+
  • macOS 10.12+

Installation

ZYGCDTimer 支持 CocoaPods 安装。在 Podfile 中写入以下文本,然后执行 pod install 即可:

pod "ZYGCDTimer"

Usage

使用 target-selector 创建定时器

+ (instancetype)timerWithTimeInterval:(NSTimeInterval)interval
                                       target:(id)aTarget
                                     selector:(SEL)aSelector
                                     userInfo:(nullable id)userInfo
                                      repeats:(BOOL)repeats
                                dispatchQueue:(dispatch_queue_t)dispatchQueue;

使用 block 创建定时器

+ (instancetype)timerWithTimeInterval:(NSTimeInterval)interval
                                     userInfo:(nullable id)userInfo
                                      repeats:(BOOL)repeats
                                dispatchQueue:(dispatch_queue_t)dispatchQueue
                                        block:(void (^)(ZYGCDTimer *timer))block;

启用定时器

- (void)fire;

无效定时器

- (void)invalidate;

暂停定时器

- (void)pause;

Author

ripperhe, [email protected]

License

ZYGCDTimer is available under the MIT license. See the LICENSE file for more info.

zygcdtimer's People

Contributors

ripperhe avatar jyhu avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.