2

Can't endBackgroundTask: no background task exists with identifier 48fcd6, or it may have already been ended. Break in UIApplicationEndBackgroundTaskError() to debug.

What I tried is here.

- (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];
}

so my question is why I am getting this error/warning.Is there any solution because this interupts my notification timer and timer is getting fired before the actual timer time.

4

0 回答 0