gpt4 book ai didi

ios - NSTimer 选择器不重复

转载 作者:行者123 更新时间:2023-11-28 22:35:18 25 4
gpt4 key购买 nike

在我的 AppDelegate 中我定义了

AppDelegate.h

@property (strong, nonatomic) NSTimer *notificationTimer;

AppDelegate.m

@synthesize notificationTimer = _notificationTimer;

- (void)applicationDidBecomeActive:(UIApplication *)application {
NSLog(@"applicationDidBecomeActive");
self.notificationTimer = [NSTimer timerWithTimeInterval:5
target:self
selector:@selector(checkForNotifications:)
userInfo:nil
repeats:YES];
[self.notificationTimer fire];
}

checkForNotifications: 只到达一次,但不会重复。为什么?

最佳答案

使用:
self.notificationTimer = [NSTimer scheduledTimerWithTimeInterval:5 target:self selector:@selector(checkForNotifications) userInfo:nil repeats:YES];

关于ios - NSTimer 选择器不重复,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16245352/

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