Hey all,
As soon as a user logs in, a timer is set to go off in specific time, if they choose not to remember their login. So regardless of which view controller they are on, after this specific time period, I want them to return to the login screen. Problem is within the LoginViewController, I am not sure how to reference the controller that they are on and to push them back to the login controller:
This line of code just pushes to previous controller of current controller:
But I want to always return to login controller.
This here:
raises exception:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Pushing the same view controller instance more than once is not supported (<LoginViewController: 0x7b35990>)'
thanks for response
As soon as a user logs in, a timer is set to go off in specific time, if they choose not to remember their login. So regardless of which view controller they are on, after this specific time period, I want them to return to the login screen. Problem is within the LoginViewController, I am not sure how to reference the controller that they are on and to push them back to the login controller:
Code:
if(!self.isRememberable){
[NSTimer scheduledTimerWithTimeInterval:30.0 target:self selector:@selector(dismissView) userInfo:nil repeats:NO];
}
- (void)dismissView
{
User *currentUser = [UserManager currentUser];
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"http://%@/pages/logout.json?auth_token=%@", RemoteUrl, currentUser.auth_token]];
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
[request startSynchronous];
NSError *error = [request error];
if (error) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Alert" message:[error description] delegate:self cancelButtonTitle:@"OK" otherButtonTitles: nil];
[alert show];
} else {
NSString *response = [request responseString];
NSDictionary * resultsDictionary = [response objectFromJSONString];
NSString * success = [resultsDictionary objectForKey:@"success"];
if([success boolValue]){
currentUser.auth_token = nil;
[self.navigationController popViewControllerAnimated:YES];
}
}
}
This line of code just pushes to previous controller of current controller:
Code:
[self.navigationController popViewControllerAnimated:YES];
But I want to always return to login controller.
This here:
Code:
[self.navigationController pushViewController:self animated:YES];
raises exception:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Pushing the same view controller instance more than once is not supported (<LoginViewController: 0x7b35990>)'
thanks for response