//LoginViewController.h
#import <UIKit/UIKit.h>@interface LoginViewController : UIViewController {
IBOutlet UITextField *usernameField;
IBOutlet UITextField *passwordField;
IBOutlet UIButton *loginButton;
}
@property (nonatomic, retain) UITextField *usernameField;
@property (nonatomic, retain) UITextField *passwordField;
@property (nonatomic, retain) UIButton *loginButton;
- (IBAction) login: (id) sender;
@end
//LoginViewController.m
#import "LoginViewController.h"
@implementation LoginViewController
@synthesize usernameField, passwordField, oginButton, loginIndicator;
- (IBAction) login: (id) sender
{
if([usernameField.text length] > 0 && [passwordField.text length] > 0){
if([usernameField.text isEqualToString:@"admin"] && [passwordField.text isEqualToString:@"admin"]){
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Authentication Success" message:@"Login Successful" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
} else {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Authentication Failed" message:@"Please check the username and password" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
}
}
}