Question

With reference to my question asked Change Tab view after certain time interval received as response from Server request, I used following code to show the session timeout message when application comes to active state

Method in AppDelegate.m:

- (void)applicationDidBecomeActive:(UIApplication *)application
{
    // to check the session
    XTabViewController *XTabViewCon = [[XTabViewController alloc] init];
    [XTabViewCon pushViewUponCheckedSession];
    [XTabViewCon release];
}

Methods from XTabViewController.m

- (void)pushViewUponCheckedSession {
    //THIS IS VERY IMPORTANT. IT CHECKS FOR SESSION
    if ([[[ApplicationContext alloc] dataManager ] checkSession]) {
        [self showSessionAliveView];
        //here I can write something that will push a view that was seen last before leaving app to inactive state. May be NSNotification could help me
    }
    else {
        [self showSessionTimeOutView];
    }
}
- (void)showSessionTimeOutView {
    //show activity indi
    waitingIndicator = [[MyWaitingIndicator alloc]init];
    [self.view addSubview:waitingIndicator];
    [waitingIndicator setHidden:YES];
    [waitingIndicator stopAnimating];
    //push session timeout view
    SessionTimeOutViewController *sessionTimeOutView = [[SessionTimeOutViewController alloc] init];
    [[self navigationController] pushViewController:sessionTimeOutView animated:NO];
    [sessionTimeOutView release];
    [waitingIndicator release];
}

- (void)showSessionAliveView {
    SessionAliveView *sessionAliveViewList = [[SessionAliveView alloc] init];
    [[self navigationController] pushViewController:sessionAliveViewList animated:YES];
    [sessionAliveViewList release];
}

My question is:

It(pushViewUponCheckedSession) works fine when I used it while switching between Tabs to check if session is expired.

- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController {
    //if X Tab is selected then & only then call this method
    if (tabBarController.selectedIndex == 2) {
         [XTabViewCon pushViewUponCheckedSession];
    }

}

But it fails to show the SessionTimeOutViewController's view upon checkedSession When App comes to active state, Do I need to do something like flushing the previous views. And then populate appropriate view by checking the session.

Thanks in advance

Was it helpful?

Solution

Releasing XTabViewCon just after your method call is dangerous no ? You have to be sure that your aren't using your object before releasing it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top