12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- //
- // YYTimer.h
- // YYKit <https://github.com/ibireme/YYKit>
- //
- // Created by ibireme on 15/2/7.
- // Copyright (c) 2015 ibireme.
- //
- // This source code is licensed under the MIT-style license found in the
- // LICENSE file in the root directory of this source tree.
- //
- #import <Foundation/Foundation.h>
- NS_ASSUME_NONNULL_BEGIN
- /**
- YYTimer is a thread-safe timer based on GCD. It has similar API with `NSTimer`.
- YYTimer object differ from NSTimer in a few ways:
-
- * It use GCD to produce timer tick, and won't be affected by runLoop.
- * It make a weak reference to the target, so it can avoid retain cycles.
- * It always fire on main thread.
-
- */
- @interface YYTimer : NSObject
- + (YYTimer *)timerWithTimeInterval:(NSTimeInterval)interval
- target:(id)target
- selector:(SEL)selector
- repeats:(BOOL)repeats;
- - (instancetype)initWithFireTime:(NSTimeInterval)start
- interval:(NSTimeInterval)interval
- target:(id)target
- selector:(SEL)selector
- repeats:(BOOL)repeats NS_DESIGNATED_INITIALIZER;
- @property (readonly) BOOL repeats;
- @property (readonly) NSTimeInterval timeInterval;
- @property (readonly, getter=isValid) BOOL valid;
- - (void)invalidate;
- - (void)fire;
- @end
- NS_ASSUME_NONNULL_END
|