-(void)checkLoginStatus { NSUserDefaults *pref=[NSUserDefaults standardUserDefaults]; NSString *userId=[pref objectForKey:@"user_id"]; if(userId!=nil) { UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@"Already Logged in!" message:@"You are already logged in." delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil]; [alert show]; UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName: @"Main_iPhone" bundle:[NSBundle mainBundle]]; PasswordVC*password = [mainStoryboard instantiateViewControllerWithIdentifier: @"invite"]; [self presentViewController:password animated:YES completion:nil]; } else{ UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@"please log in first!" message:@"You are not logged in." delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil]; [alert show]; } }