Reputation: 8947
I have an iPhone application in which I am using autologin. So I am storing the credentials in local and doing the autologin.I have a logout button in the application in which I am popping back to login controller in my stack. But if the user clears the app in the background (by doubleclicking the Home button) then when he tries to logout in my app, there is no login view controller on the stack (because of autologin). Then the logout button doesn't work. Can anybody help me in tackling this situation? I am logging out like this:
NSArray *array1 = [del.navigationController viewControllers];
NSLog(@"%@",[del.navigationController viewControllers]);
[del.navigationController popToViewController:[array1 objectAtIndex:0] animated:YES];
Upvotes: 0
Views: 131
Reputation: 6954
NSArray *array1 = [del.navigationController viewControllers];
NSLog(@"%@",[del.navigationController viewControllers]);
[del.navigationController popToViewController:[array1 objectAtIndex:0] animated:YES];
[array1 objectAtIndex:0]
in that case wont be your login view .
So you can keep a condition like this :
UIViewController *vw = (UIViewController *) [array1 objectAtIndex:0];
if([vw isKindOfClass:[login class])
[del.navigationController popToViewController:[array1 objectAtIndex:0] animated:YES];
else
{
// init ur login class and push that to nav stack.
}
Upvotes: 1