Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ripperhe/zygcdtimer
GCD 定时器
https://github.com/ripperhe/zygcdtimer
gcdtimer ios objective-c timer
Last synced: 3 months ago
JSON representation
GCD 定时器
- Host: GitHub
- URL: https://github.com/ripperhe/zygcdtimer
- Owner: ripperhe
- License: mit
- Created: 2017-02-15T08:42:35.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2019-09-29T06:34:06.000Z (over 5 years ago)
- Last Synced: 2024-11-08T09:24:47.670Z (3 months ago)
- Topics: gcdtimer, ios, objective-c, timer
- Language: Objective-C
- Homepage:
- Size: 46.9 KB
- Stars: 69
- Watchers: 5
- Forks: 7
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ZYGCDTimer
[![Version](https://img.shields.io/cocoapods/v/ZYGCDTimer.svg?style=flat)](http://cocoapods.org/pods/ZYGCDTimer)
[![License](https://img.shields.io/cocoapods/l/ZYGCDTimer.svg?style=flat)](http://cocoapods.org/pods/ZYGCDTimer)
[![Platform](https://img.shields.io/cocoapods/p/ZYGCDTimer.svg?style=flat)](http://cocoapods.org/pods/ZYGCDTimer)ZYGCDTimer 主要用于替代 `NSTimer`,不会强持有 target,基于 [MSWeakTimer](https://github.com/mindsnacks/MSWeakTimer) 进行修改的,本质上是个 `GCD` 定时器。
## Features
- [x] 弱引用 `target`
- [x] `target` 销毁之后,自动调用 `invalidate`
- [x] 支持 `block` 创建定时器
- [x] 支持设置 `GCD queue`
- [x] 支持暂停定时器## Example
![](zygcdtimer.png)
下载 demo 直接运行即可
## Requirements
* iOS 8.0+
* macOS 10.12+## Installation
ZYGCDTimer 支持 [CocoaPods](http://cocoapods.org) 安装。在 `Podfile` 中写入以下文本,然后执行 `pod install` 即可:
```ruby
pod "ZYGCDTimer"
```## Usage
使用 `target-selector` 创建定时器
```objc
+ (instancetype)timerWithTimeInterval:(NSTimeInterval)interval
target:(id)aTarget
selector:(SEL)aSelector
userInfo:(nullable id)userInfo
repeats:(BOOL)repeats
dispatchQueue:(dispatch_queue_t)dispatchQueue;
```使用 `block` 创建定时器
```objc
+ (instancetype)timerWithTimeInterval:(NSTimeInterval)interval
userInfo:(nullable id)userInfo
repeats:(BOOL)repeats
dispatchQueue:(dispatch_queue_t)dispatchQueue
block:(void (^)(ZYGCDTimer *timer))block;
```启用定时器
```objc
- (void)fire;
```无效定时器
```objc
- (void)invalidate;
```暂停定时器
```objc
- (void)pause;
```## Author
ripperhe, [email protected]
## License
ZYGCDTimer is available under the MIT license. See the LICENSE file for more info.