Latest 1.0.2
Homepage https://github.com/ooppstef/ZCLooper
License MIT
Platforms ios 7.0, requires ARC
Authors
  • 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'

Latest podspec

{
    "name": "ZCLooper",
    "version": "1.0.2",
    "summary": "Better performance Timer",
    "homepage": "https://github.com/ooppstef/ZCLooper",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "platforms": {
        "ios": "7.0"
    },
    "source": {
        "git": "https://github.com/ooppstef/ZCLooper.git",
        "tag": "1.0.2"
    },
    "source_files": "ZCLooper/ZCLooper/**/*.{h,m}",
    "authors": {
        "Charles": "[email protected]"
    },
    "requires_arc": true
}

Pin It on Pinterest

Share This