无法endBackgroundTask:标识符48fcd6不存在后台任务,或者它可能已经结束。中断UIApplicationEndBackgroundTaskError()以进行调试。
我尝试的是这里。
- (void)applicationDidEnterBackground:(UIApplication *)application
{
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
NSString *myString = [prefs stringForKey:@"getTime"];
int timeInterval = [myString integerValue];
intervalForTimer = timeInterval;
[timer invalidate];
timer=nil;
timer = [ NSTimer
scheduledTimerWithTimeInterval:intervalForTimer
target:self
selector:@selector(startCoreUpdate)
userInfo:nil
repeats:YES
];
//change to NSRunLoopCommonModes
[ [NSRunLoop currentRunLoop]
addTimer:timer
forMode:NSRunLoopCommonModes
];
[[NSRunLoop currentRunLoop] run];
});
UIBackgroundTaskIdentifier back =
[[UIApplication sharedApplication]
beginBackgroundTaskWithExpirationHandler:^{
[self startCoreUpdate];
[ [UIApplication sharedApplication]
endBackgroundTask:back
];
} ];
}
-(void) startCoreUpdate{
notification=[[AlertNotificationViewController alloc]init];
[notification recentUpdatesVideo];
}
所以我的问题是为什么我收到此错误/警告。是否有任何解决方案,因为这会中断我的通知计时器并且计时器在实际计时器时间之前被触发。