after finding a good solution about a missing Segue execution thanks to this post
I'm clashing against another problem: Following the approach described in the aforementioned post I'm performing the check for my auth token in the Dashboard VC and,if not set,I activate a segue pointing to the LoginVC exploiting the delegate mechanism in order to dismiss the view once the operation is completed. Now,the problem is that on the very first run I got the Dashboard VC show for a moment before the LoginVC gets displayed. I would like to show the Login screen immediately hiding (somehow) the Dashboard VC. In other words I want the user to not notice what's really going on underneath.
Any idea? This is my current storyboard setup
and I check for my credentials in the DashboardVC like that:
- (void)viewWillAppear:(BOOL)animated {
//check if the token is set,if not trigger the Login screen
NSString* token = nil;
NSUserDefaults* userPref = [NSUserDefaults standardUserDefaults];
token = [userPref objectForKey:@"AuthToken"];
if (token == nil) {
NSLog(@"Token not present,Login required!");
[self performSegueWithIdentifier:@"sLogin" sender:nil];
[super viewWillAppear:NO];
}
//[super viewWillAppear:YES];
}
// if the Segue was triggered by the "Logout" button we erase the token otherwise
// simply perform the login since there was no token at all
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([sender tag] == 5) {
NSLog(@"User selected Logout");
//remove the token
NSUserDefaults* userPref = [NSUserDefaults standardUserDefaults];
[userPref removeObjectForKey:@"AuthToken"];
[userPref synchronize];
NSLog(@"Token removed.");
}
if ([segue.identifier isEqualToString:@"sLogin"]) {
LoginViewController *livc = segue.destinationViewController;
livc.delegate = self; // For the delegate method
}
}
@ElJay,I might need your help again :)
Thanks everybody!