STWeakTimer 0.0.4

STWeakTimer 0.0.4

测试已测试
语言语言 Obj-CObjective C
许可协议 MIT
发布最后发布2018年8月

Suta维护。



  • Suta

STWeakTimer

Version License Platform

NSTimer的替代方案。

STWeakTimer是NSTimer的替代方案,它不会引起引用循环,是线程安全的。

STWeakTimerPreview01

需求

  • iOS 8.0 或更高版本(对于iOS 8.0之前的版本,可能也能工作,但我还没有测试过。)
  • ARC

安装

STWeakTimer可通过CocoaPods获得。安装它简单地添加以下行到您的Podfile中

pod 'STWeakTimer'

使用

在源文件中导入头文件

在需要使用库的源文件中,导入头文件

#import <STWeakTimer/STWeakTimer.h>

初始化 STWeakTimer

初始化一个 STWeakTimer,您可以使用选择器或块作为回调。还可以设置线程以执行回调

STWeakTimer *timer = [STWeakTimer scheduledTimerWithTimeInterval:1 userInfo:nil repeats:YES dispatchQueue:dispatch_get_main_queue() handler:^(STWeakTimer * _Nullable timer) {
    NSLog(@"Timer triggered");
}];

控制 STWeakTimer

STWeakTimer 支持暂停和恢复

[timer pause];
[timer resume];

作者

Suta, [email protected]

许可证

MIT许可证.