iOS中使用dispatch_apply来重复执行任务,但计时器无法运行
iOS中使用了MZTimerLabel做为计时器添加到任务中,然后使用dispatch_apply来重复执行任务,但计时器无法计时,而且不时在MZTimerLabel中实现的start方法中崩溃[[NSRunLoop currentRunLoop] addTimer:_timer forMode:NSRunLoopCommonModes];
以下是我的代码,timer是引用MZTimerLabel中的第三方,可以在GitHub搜到。
BLOCK myBlock = ^(size_t size){
//如果是单词模式
if (self.typer ==2) {
[timer2 setCountDownTime:[self.timeCount integerValue]*60/2];
[timer2 start];
[timer2 startWithEndingBlock:^(NSTimeInterval countTime) {
[self showView];
}];
}else{
[timer2 setCountDownTime:[self.timeCount integerValue]*60];
[timer2 start];
[timer2 startWithEndingBlock:^(NSTimeInterval countTime) {
agolab.text = @"休息时间";
if([self.rest integerValue]!=0){
[timer2 start]