gpt4 book ai didi

objective-c - NSTimer 的问题

转载 作者:行者123 更新时间:2023-12-03 17:41:52 25 4
gpt4 key购买 nike

我在使用 NSTimers 时遇到了很多麻烦。我以前用过它们,但这个计时器就是不想触发。

-(void) enqueueRecordingProcess
{
NSLog(@"made it!");
NSTimer *time2 = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(warnForRecording) userInfo:nil repeats:YES];

}

-(void) warnForRecording
{
NSLog(@"timer ticked!");
if (trv > 0) {
NSLog(@"Starting Recording in %i seconds.", trv);
}
}

我不明白为什么这不能运行。我什至尝试过这个:

- (void)enqueueRecordingProcess
{
NSLog(@"made it!");
[NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(warnForRecording) userInfo:nil repeats:YES];
}

- (void)warnForRecording
{
NSLog(@"timer ticked!");
}

出了什么问题?

最佳答案

不确定这是否可以解决问题,但来自 docs :

The message to send to target when the timer fires. The selector must have the following signature:
- (void)timerFireMethod:(NSTimer*)theTimer
The timer passes itself as the argument to this method.

关于objective-c - NSTimer 的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10874816/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com