Inherits from NSObject
Declared in SGSCountdownTask.h

Overview

倒计时任务类,只有一个倒计时任务时,推荐使用该类

Tasks

Properties

backgroundTaskIdentifier

@property (nonatomic, assign) UIBackgroundTaskIdentifier backgroundTaskIdentifier
Discussion

后台任务标识,确保App进入后台后依然能够进行计时

Declared In

SGSCountdownTask.h

countdown

@property (nonatomic, assign, readonly, getter=isCounting) BOOL countdown
Discussion

是否处于倒计时状态

Declared In

SGSCountdownTask.h

countingHandler

@property (nullable, nonatomic, copy) void ( ^ ) ( NSTimeInterval timeInterval ) countingHandler
Discussion

计时进行中的回调Block

Declared In

SGSCountdownTask.h

finishedHandler

@property (nullable, nonatomic, copy) void ( ^ ) ( NSTimeInterval timeInterval ) finishedHandler
Discussion

计时结束后的回调Block

Declared In

SGSCountdownTask.h

identifier

@property (nonnull, nonatomic, copy) NSString *identifier
Discussion

倒计时任务标识符

Declared In

SGSCountdownTask.h

Instance Methods

cancel

停止倒计时

- (void)cancel

Declared In

SGSCountdownTask.h

initWithIdentifier:countingHandler:finishedHandler:

指定初始化方法

- (nullable instancetype)initWithIdentifier:(nullable NSString *)identifier countingHandler:(nullable void ( ^ ) ( NSTimeInterval timeInterval ))countingHandler finishedHandler:(nullable void ( ^ ) ( NSTimeInterval timeInterval ))finishedHandler

Parameters

identifier

倒计时任务唯一标识符

countingHandler

倒计时进行中的Block

finishedHandler

倒计时完毕的Block

Return Value

SGSCountdownTask or nil

Declared In

SGSCountdownTask.h

scheduledWithTimeout:

- (void)scheduledWithTimeout:(NSTimeInterval)timeInterval
Discussion

由于操作系统后台限制,如果设置了backgroundTaskIdentifier, 倒计时时间规定不得大于120秒,除非是音乐播放器或运动类APP

Parameters

timeInterval

倒计时时间

Declared In

SGSCountdownTask.h