How do I set a password for a login and then segue to another ViewController when it is correct?

Here is my code:

- (IBAction)login:(id)sender {
    UIAlertView *message = [[UIAlertView alloc] initWithTitle:@"Login"
                                                      message:@"Enter your username & password"
                                                     delegate:self 
                                            cancelButtonTitle:@"Cancel" 
                                            otherButtonTitles:@"Login", nil];

    [message setAlertViewStyle:UIAlertViewStyleLoginAndPasswordInput];

    [message show];
}

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
    NSString *title = [alertView buttonTitleAtIndex:buttonIndex];

    if([title isEqualToString:@"Login"])
    {
        UITextField *username = [alertView textFieldAtIndex:0];
        UITextField *password = [alertView textFieldAtIndex:1]; 
    }
}

Answers


Create an Objective c class with two properties (userName and Password).. Then modify your code

     -(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex { 

           NSString *title = [alertView buttonTitleAtIndex:buttonIndex];

           if([title isEqualToString:@"Login"]) { 

                UITextField *username = [alertView textFieldAtIndex:0]; 
                UITextField *password = [alertView textFieldAtIndex:1];

Validate your password and user name using **username.text and password.text**

if its valid then

                //create an Object the for the class which holds UserName and Password and set the values.
                newObj.userName = username.text;
                newObj.password = password.text;

               pass the object from here where you want'
               release the newObj
        } 
    }

When you've validated tbe username and password --

[self performSegueWithIdentifier:@"LoginSegue" sender:self];

Create "LoginSegue" in your storyboard from the controller that gets the login info to the controller you want to show after login.


Need Your Help

Using icacls to set permissions of a folder to inherit recursively

windows icacls

I want to set a specific folder with specific rights to inherit all rights of it's parent folder. I know I should use icacls.

Excel VBA - Find _ or . in word then put word in seperate field

excel vba excel-vba find

I have a large list of cells that contain SQL within each cell. I want to find any word with a _ or . and then pull that word from the cell and put in adjacent cell.