BBATimer.h
9.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
//
// BBATimer
// BBAPods
//
// Created by 白昆仑 on 2017/8/2.
// Copyright © 2017年 Baidu. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "BDPFoundationDefines.h"
/**
* Timer相关的扩展,提供封装好的 block 定时器和 selector 定时器
* 详细介绍请看README-BBATimer
*/
/*!
@block
@brief 定时器触发回调闭包
@param timer 定时器对象
@param target 目标对象(使用该对象可避免循环引用)
@param repeatTimes 设置的定时器触发总次数
@param repeatCount 定时器当前触发的次数
@result 返回YES,继续定时器逻辑;NO,立即停止定时器
*/
typedef BOOL (^BBATimerBlock)(NSTimer *timer, id target, NSUInteger repeatTimes, NSUInteger repeatCount);
@interface NSTimer (BBABuilder)
#pragma mark - Block定时器
/*!
@method
@brief 创建一个NSTimer对象
@param interval 定时器触发时间间隔
@param isRepeat 是否重复触发定时
@param aTarget 目标对象,该对象会在block回调中回传,使用该对象可避免循环引用
@param block 回调函数
@result NSTimer对象
*/
+ (instancetype)bba_timerWithTimeInterval:(NSTimeInterval)interval
repeats:(BOOL)isRepeat
target:(id)aTarget
block:(BBATimerBlock)block BDP_FOUNDATION_DEPRECATED("please use bdp_timerWithTimeInterval:repeats:target:block:");
+ (instancetype)bdp_timerWithTimeInterval:(NSTimeInterval)interval
repeats:(BOOL)isRepeat
target:(id)aTarget
block:(BBATimerBlock)block;
/*!
@method
@brief 创建一个NSTimer对象
@param interval 定时器触发时间间隔
@param isRepeat 是否重复触发定时
@patam repeatTimes 定时器触发次数,设置为0表示不限制触发次数(该参数仅在isRepeat=YES下生效)
@param aTarget 目标对象,该对象会在block回调中回传,使用该对象可避免循环引用
@param block 回调函数
@result NSTimer对象
*/
+ (instancetype)bba_timerWithTimeInterval:(NSTimeInterval)interval
repeats:(BOOL)isRepeat
repeatTimes:(NSUInteger)repeatTimes
target:(id)aTarget
block:(BBATimerBlock)block BDP_FOUNDATION_DEPRECATED("please use bdp_timerWithTimeInterval:repeats:repeatTimes:target:block:");
+ (instancetype)bdp_timerWithTimeInterval:(NSTimeInterval)interval
repeats:(BOOL)isRepeat
repeatTimes:(NSUInteger)repeatTimes
target:(id)aTarget
block:(BBATimerBlock)block;
/*!
@method
@brief 创建一个NSTimer对象,并开启定时器
@param interval 定时器触发时间间隔
@param isRepeat 是否重复触发定时
@param aTarget 目标对象,该对象会在block回调中回传,使用该对象可避免循环引用
@param block 回调函数
@result NSTimer对象
*/
+ (instancetype)bba_scheduleTimerWithTimeInterval:(NSTimeInterval)interval
repeats:(BOOL)isRepeat
target:(id)aTarget
block:(BBATimerBlock)block BDP_FOUNDATION_DEPRECATED("please use bdp_scheduleTimerWithTimeInterval:repeats:target:block:");
+ (instancetype)bdp_scheduleTimerWithTimeInterval:(NSTimeInterval)interval
repeats:(BOOL)isRepeat
target:(id)aTarget
block:(BBATimerBlock)block;
/*!
@method
@brief 创建一个NSTimer对象,并开启定时器
@param interval 定时器触发时间间隔
@param isRepeat 是否重复触发定时
@patam repeatTimes 定时器触发次数,设置为0表示不限制触发次数(该参数仅在isRepeat=YES下生效)
@param aTarget 目标对象,该对象会在block回调中回传,使用该对象可避免循环引用
@param block 回调函数
@result NSTimer对象
*/
+ (instancetype)bba_scheduleTimerWithTimeInterval:(NSTimeInterval)interval
repeats:(BOOL)isRepeat
repeatTimes:(NSUInteger)repeatTimes
target:(id)aTarget
block:(BBATimerBlock)block BDP_FOUNDATION_DEPRECATED("please use bdp_scheduleTimerWithTimeInterval:repeats:repeatTimes:target:block:");
+ (instancetype)bdp_scheduleTimerWithTimeInterval:(NSTimeInterval)interval
repeats:(BOOL)isRepeat
repeatTimes:(NSUInteger)repeatTimes
target:(id)aTarget
block:(BBATimerBlock)block;
#pragma mark - Selector定时器
/*!
@method
@brief 创建一个NSTimer对象
@param interval 定时器触发时间间隔
@param isRepeat 是否重复触发定时
@param aTarget 目标对象,该对象会在block回调中回传,使用该对象可避免循环引用
@param aSelector 目标对象的调用方法
@result NSTimer对象
*/
+ (instancetype)bba_timerWithTimeInterval:(NSTimeInterval)interval
repeats:(BOOL)isRepeat
target:(id)aTarget
selector:(SEL)aSelector BDP_FOUNDATION_DEPRECATED("please use bdp_timerWithTimeInterval:repeats:target:selector:");
+ (instancetype)bdp_timerWithTimeInterval:(NSTimeInterval)interval
repeats:(BOOL)isRepeat
target:(id)aTarget
selector:(SEL)aSelector;
/*!
@method
@brief 创建一个NSTimer对象
@param interval 定时器触发时间间隔
@param isRepeat 是否重复触发定时
@patam repeatTimes 定时器触发次数,设置为0表示不限制触发次数(该参数仅在isRepeat=YES下生效)
@param aTarget 目标对象,该对象会在block回调中回传,使用该对象可避免循环引用
@param aSelector 目标对象的调用方法
@param userInfo 调用目标方法的回传参数
@result NSTimer对象
*/
+ (instancetype)bba_timerWithTimeInterval:(NSTimeInterval)interval
repeats:(BOOL)isRepeat
repeatTimes:(NSUInteger)repeatTimes
target:(id)aTarget
selector:(SEL)aSelector
userInfo:(id)userInfo BDP_FOUNDATION_DEPRECATED("please use bdp_timerWithTimeInterval:repeats:repeatTimes:target:selector:userInfo:");
+ (instancetype)bdp_timerWithTimeInterval:(NSTimeInterval)interval
repeats:(BOOL)isRepeat
repeatTimes:(NSUInteger)repeatTimes
target:(id)aTarget
selector:(SEL)aSelector
userInfo:(id)userInfo;
/*!
@method
@brief 创建一个NSTimer对象,并开启定时器
@param interval 定时器触发时间间隔
@param isRepeat 是否重复触发定时
@param aTarget 目标对象,该对象会在block回调中回传,使用该对象可避免循环引用
@param aSelector 目标对象的调用方法
@result NSTimer对象
*/
+ (instancetype)bba_scheduleTimerWithTimeInterval:(NSTimeInterval)interval
repeats:(BOOL)isRepeat
target:(id)aTarget
selector:(SEL)aSelector BDP_FOUNDATION_DEPRECATED("please use bdp_scheduleTimerWithTimeInterval:repeats:target:selector:");
+ (instancetype)bdp_scheduleTimerWithTimeInterval:(NSTimeInterval)interval
repeats:(BOOL)isRepeat
target:(id)aTarget
selector:(SEL)aSelector;
/*!
@method
@brief 创建一个NSTimer对象,并开启定时器
@param interval 定时器触发时间间隔
@param isRepeat 是否重复触发定时
@patam repeatTimes 定时器触发次数,设置为0表示不限制触发次数(该参数仅在isRepeat=YES下生效)
@param aTarget 目标对象,该对象会在block回调中回传,使用该对象可避免循环引用
@param aSelector 目标对象的调用方法
@param userInfo 调用目标方法的回传参数
@result NSTimer对象
*/
+ (instancetype)bba_scheduleTimerWithTimeInterval:(NSTimeInterval)interval
repeats:(BOOL)isRepeat
repeatTimes:(NSUInteger)repeatTimes
target:(id)aTarget
selector:(SEL)aSelector
userInfo:(id)userInfo BDP_FOUNDATION_DEPRECATED("please use bdp_scheduleTimerWithTimeInterval:repeats:repeatTimes:target:selector:userInfo:");
+ (instancetype)bdp_scheduleTimerWithTimeInterval:(NSTimeInterval)interval
repeats:(BOOL)isRepeat
repeatTimes:(NSUInteger)repeatTimes
target:(id)aTarget
selector:(SEL)aSelector
userInfo:(id)userInfo;
@end