2

I am experimenting with developing my first app. I need some help on moving from one view controller to the next after a successful login. I've looked up countless methods but just don't seem to understand. this is what I have so far:

   #import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    credentialsDictionary = [[NSDictionary alloc] initWithObjects:[NSArray arrayWithObjects:@"password", nil] forKeys:[NSArray arrayWithObjects:@"username", nil]];
    
}


- (IBAction)SubmitCredentials;

{
    if ([[credentialsDictionary objectForKey:badgenumberField.text]isEqualToString:passwordField.text]) {
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Valid Credentials" message:@"Access Granted." delegate:self cancelButtonTitle:@"Dismiss" otherButtonTitles:nil];

    }
    else {
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Invalid Credentials" message:@"Access Denied." delegate:self cancelButtonTitle:@"Dismiss" otherButtonTitles:nil];
        [alert show];
        
        
    }
    

;}
@end

Can someone help me get to the next step please it would be greatly appreciated. Can you also let me know what segue i should be using to move to the next controller after the successful login.

Dharman
  • 30,962
  • 25
  • 85
  • 135
w.cruz
  • 23
  • 5
  • 1
    Take a look [here](http://stackoverflow.com/questions/19962276/best-practices-for-storyboard-login-screen-handling-clearing-of-data-upon-logou/21873051#21873051). It has ALL the answers you need. – mfaani Oct 03 '16 at 14:15

1 Answers1

0

After you verify the correct credentials, if you are not using storyboard you should initialize other view controller and them push to it.

something like this:

HomeViewController *ctrl = [[HomeViewController alloc] initWithNibName:[[BaseHomeViewController class] description] bundle:nil]; [self.navigationController pushViewController:ctrl animated:YES];

change HomeViewControllerto the view controller that you wanna move

if you are not using a baseViewController like this:

//  HomeViewController.h

#import "BaseHomeViewController.h"

@interface HomeViewController : BaseHomeViewController

@end

Change the file BaseViewController to your xib view controller class