CocoaPods trunk is moving to be read-only. Read more on the blog, there are 17 months to go.

ZCLooper 1.0.2

ZCLooper 1.0.2

TestsTested
LangLanguage Obj-CObjective C
License MIT
ReleasedLast Release Apr 2016

Maintained by ooppstef.



ZCLooper 1.0.2

  • By
  • Charles
  • Better performance Timer.
  • Using CADisplaylink instead of NSTimer. More precise.
  • Default NSRunLoopCommonModes.
  • Using block instead of target-action.
  • Max/min delay to support some asynchronous actions/time consuming actions
  • Supports pausing and resuming

Usage

Normal Timer(as NSTimer)

No need to deal with isResponseReturned

_looper = [ZCLooper new];
_looper.retryMinTimes = 1;
_looper.repeatTimeSpace = 1;

//repeat in 1 * 1 = 1s
[_looper startLooperWithHandler:^(ZCLooper *looper) {
    NSLog(@"hello");
}
[_looper fire];

Timer for asynchronous actions(eg:networking)

You have to deal with the property:isResponseReturned

This property tells the looper the handler complated,or it will repeat as the max delay

_looper = [ZCLooper new];
_looper.retryMaxTimes = 20;
_looper.retryMinTimes = 10;
_looper.repeatTimeSpace = 0.5;

//max repeat in 20 * 0.5 = 10s, min in 10 * 0.5 = 5s
[_looper startLooperWithHandler:^(ZCLooper *looper) {
    NSURLSession *session...
    NSURLSessionTask *task = [session dataTaskWithRequest:request completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {

    //deal with isResponseReturned
     looper.isResponseReturned = YES;
    }];
    [task resume];

}
[_looper fire];

Requirements

iOS7+ and ARC

Installation

Available through CocoaPods

pod 'ZCLooper'