STWeakTimer 0.0.4

STWeakTimer 0.0.4

TestsTested
LangLanguage Obj-CObjective C
License MIT
ReleasedLast Release Aug 2018

Maintained by Suta.



  • By
  • Suta

STWeakTimer

Version License Platform

An alternative to NSTimer.

STWeakTimer is an alternative to NSTimer, it does not cause the retain cycle, it is thread-safe.

STWeakTimerPreview01

Requirements

  • iOS 8.0 or later (For iOS 8.0 before, maybe it can work, but I have not tested.)
  • ARC

Installation

STWeakTimer is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'STWeakTimer'

Usage

Import headers in your source files

In the source files where you need to use the library, import the header file:

#import <STWeakTimer/STWeakTimer.h>

Initialize STWeakTimer

Initialize a STWeakTimer, you can use a selector or block as the callback. You can also set the thread to execute the callback:

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

Control STWeakTimer

STWeakTimer supports pause and resume:

[timer pause];
[timer resume];

Author

Suta, [email protected]

License

MIT license.