Latest 0.0.3
Homepage https://github.com/NearKXH/NKCWeakTimer
License MIT
Platforms ios 8.0, osx 10.10, requires ARC
Authors

中文版本.

Description

NKCWeakTimer can be used as NSTimer, but do not retain Target.

NKCWeakTimer is implemented by GCD, and all function I had considered are similar to NSTimer.

You can use NKCWeakTimer as normal NSObject, strong it, and NKCWeakTimer do not need to release in the dealloc method.

NKCWeakTimer invoke invalidate method when retainCount equre to 0, and release itself automatically. Of course, you can invoke invalidate method whenever you need.

How to Use

Create an NKCWeakTimer object with below class method, NKCWeakTimer scheduled automatically.

Using SEL as below:

+ (instancetype)scheduledTimerWithTimeInterval:(NSTimeInterval)interval
                                        target:(id)aTarget
                                      selector:(SEL)aSelector
                                      userInfo:(nullable id)userInfo
                                       repeats:(BOOL)repeats;

Using Block as below:

+ (instancetype)scheduledTimerWithTimeInterval:(NSTimeInterval)interval
                                      userInfo:(nullable id)userInfo
                                       repeats:(BOOL)repeats
                                         block:(void (^)(NKCWeakTimer *timer))block;

Installation

  • Using CocoaPods:

Just add this line to your Podfile:

pod 'NKCWeakTimer'
  • Manually:

Simply add the files NKCWeakTimer.h and NKCWeakTimer.m to your project.

Compatibility

  • Requires ARC. If you want to use it in a project without ARC, mark NKCWeakTimer with the linker flag -fobjc-arc.
  • Supports iOS iOS8+ and Mac OSX 10.10+.

Latest podspec

{
    "name": "NKCWeakTimer",
    "version": "0.0.3",
    "summary": "A delightful iOS and OS X Weak Timer.",
    "description": "`NKCWeakTimer` can be used as `NSTimer`, but do not retain Target.n`NKCWeakTimer` is implemented by `GCD`, and all founction as `NSTimer`.",
    "homepage": "https://github.com/NearKXH/NKCWeakTimer",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Near": "[email protected]"
    },
    "platforms": {
        "ios": "8.0",
        "osx": "10.10"
    },
    "source": {
        "git": "https://github.com/NearKXH/NKCWeakTimer.git",
        "tag": "0.0.3"
    },
    "source_files": "NKCWeakTimer/**/*",
    "requires_arc": true
}

Pin It on Pinterest

Share This