Objective c 目标c中不兼容的块指针类型
我在这行“[NSTimer scheduledTimerWithTimeInterval:3/self.MAX repeats:YES block:^{”中遇到了以下错误:“不兼容的块指针类型将'void(^)(void)'发送到'void(^非空)(NSTimer*.\u非空^强)'类型的参数” 提前谢谢Objective c 目标c中不兼容的块指针类型,objective-c,nstimer,Objective C,Nstimer,我在这行“[NSTimer scheduledTimerWithTimeInterval:3/self.MAX repeats:YES block:^{”中遇到了以下错误:“不兼容的块指针类型将'void(^)(void)'发送到'void(^非空)(NSTimer*.\u非空^强)'类型的参数” 提前谢谢 self.progressTimer = [NSTimer scheduledTimerWithTimeInterval:3/self.MAX repeats:YES block:^{
self.progressTimer = [NSTimer scheduledTimerWithTimeInterval:3/self.MAX repeats:YES block:^{
self.progressRight.constant = self.progressRight.constant + 1.0;
if (self.progressRight.constant >= self.MAX) {
self.ENOUGH = YES;
self.PANIC = NO;
[self.progressTimer invalidate];
[self submit];
}
}];
集体签名是错误的 自己解决这类问题
- 注释掉整个方法
- 重新键入第一个字符并使用代码补全
- 选择所需的方法
[NSTimer scheduledTimerWithTimeInterval:3/self.MAX repeats:YES block:^(NSTimer * _Nonnull timer) {
// code
}];
这就是错误消息所说的:
- 预期类型
(^非空)(NSTimer*\u非空\u强)
- 给定类型
'void(^)(void)
weakSelf
模式,即在创建计时器之前,创建typeof(self)_uu弱弱弱弱弱弱弱弱弱弱弱弱弱弱弱弱弱弱弱弱弱弱弱弱弱弱弱弱弱弱弱弱弱弱弱弱弱弱弱弱弱弱弱弱弱弱弱弱弱弱弱弱弱弱弱弱弱弱弱弱弱弱弱弱弱弱弱弱弱弱弱弱弱弱弱弱弱弱弱弱弱弱弱弱弱弱弱弱弱弱弱弱弱弱弱弱弱弱弱弱弱弱弱弱弱弱弱弱弱弱弱弱弱弱弱弱弱弱弱弱弱弱弱。