GlobalTimer
示例
要运行示例项目,请克隆仓库,然后在 Example 目录中首先运行 pod install
需求
- Xcode
- Objective-C
功能
- 使用事件启动循环。
- 暂停特定的循环。
- 激活特定的循环。
- 移除特定的循环。
- 使用新的间隔更新循环。
安装
GlobalTimer 通过 CocoaPods 提供。要安装它,只需将以下行添加到 Podfile 中
pod 'GlobalTimer'
API
+ (instancetype _Nonnull )shared;
- (void)scheduledWith: (NSString * _Nonnull )identifirer timeInterval: (NSTimeInterval)interval repeat:(BOOL)repeat block:(GTBlock _Nonnull )block userinfo:(NSDictionary * _Nullable)userinfo;
- (void)updateEventWith: (NSString * _Nonnull )identifirer timeInterval: (NSTimeInterval)interval repeat:(BOOL)repeat block:(GTBlock _Nonnull )block userinfo:(NSDictionary * _Nullable)userinfo;
- (void)pauseEventWith: (NSString *_Nonnull)identifirer;
- (void)removeEventWith: (NSString *_Nonnull)identifirer;
- (void)activeEventWith:(NSString *_Nonnull)identifirer;
- (NSArray<NSString *> *_Nonnull)eventList;
📖 用法
[[GTimer shared] scheduledWith:@"first" timeInterval:2 repeat:YES block:^(NSDictionary *userinfo) {
NSLog(@"🇺🇸%@", userinfo[@"test"]);
} userinfo:@{@"test": @"ok"}];
[[GTimer shared] scheduledWith:@"second" timeInterval:5 repeat:YES block:^(NSDictionary *userinfo) {
NSLog(@"🌺%@", userinfo[@"cnkcq"]);
} userinfo:@{@"cnkcq": @"king"}];
[[GTimer shared] scheduledWith:@"dog" timeInterval:5 repeat:YES block:^(NSDictionary *userinfo) {
NSLog(@"🐶%@", userinfo[@"dog"]);
} userinfo:@{@"dog": @"旺财"}];
[[GTimer shared] scheduledWith:@"fourth" timeInterval:10 repeat:YES block:^(NSDictionary *userinfo) {
NSLog(@"🐱%@", userinfo[@"cat"]);
} userinfo:@{@"cat": @"咪咪"}];
[[GTimer shared] pauseEventWith:@"dog"];
NSLog(@"%@", [[GTimer shared] eventList]);
[[GTimer shared] activeEventWith:@"dog"];
[[GTimer shared] removeEventWith:@"fourth"];
Reprensent
作者
[email protected], [email protected]
许可
GlobalTimer遵循MIT许可证。有关更多信息,请参阅LICENSE文件。