I have used NSTimer & at the end of countDown want to change the value of View.UILabel.text=@"Time Up"
. This is working perfectly until I switch to some other ViewController, after switching between viewController(& coming back to this viewController) when countDown is complete I am getting perfect values & their is no nil but View.UILabel.text value is not changing, I have checked exceptions, no exception get raised.
My Code:
-(void) timeInterval
{
appdelegate._UserProfile.totalTime = 30;
UIApplication *app = [UIApplication sharedApplication];
//will allow NSTimer to continue running in background..
UIBackgroundTaskIdentifier bgTask = 0;
bgTask = [app beginBackgroundTaskWithExpirationHandler:^{
[app endBackgroundTask:bgTask];
}];
appdelegate._UserProfile.timer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(countDown) userInfo:nil repeats:YES];
}
-(void) countDown
{
appdelegate._UserProfile.totalTime -= 1;
if(appdelegate._UserProfile.totalTime == 0)
{
[profileView.userPhoneNo setText:@""];
profileView.timeUp.text= @"* Time Up";
}
}
Please any help will be very appreciated. (I have seen many questions but my issue is not solved)
*Note: After switch if i change the value of label in ViewWillAppear() it is working perfect, but i need to change text when countDown is completed. I am using UINavigationController & MFSideMenuManager
to switch between ViewControllers.
My Navigation Code:
-(void) initMyProfile
{
UINavigationController *detailNavigationController = [MFSideMenuManager sharedManager].navigationController;
detailNavigationController.menuState = MFSideMenuStateHidden;
MyProfileViewController_iPhone* detailViewController = [[MyProfileViewController_iPhone alloc] initWithNibName:nil bundle:nil];
detailViewController.title = @"My Profile";
detailNavigationController.viewControllers = [NSArray arrayWithObject:detailViewController];
}