- (IBAction)refreshInformation:(id)sender;
- (int)verifyUserInput;
- (void)handleErrors:(int)errorNumber;
- (IBAction)refreshInformation:(id)sender {
NSInteger funcReturn = 0;
// Verify they have entered everything we need to get the information
funcReturn = [self verifyUserInput];
// Did we have any errors?
if (funcReturn) {
[self handleErrors:funcReturn];
}
}
- (int)verifyUserInput {
// Initialize some local variables with the input from the user
NSString *nameString = userName.text;
NSString *passString = userPassword.text;
NSString *serverString = serverAddress.text;
// Verify that people are putting the right stuff into the fields
if ([nameString length] == 0) {
return 11;
} else if ([passString length] == 0) {
return 11;
} else if ([serverString length] == 0) {
return 11;
}
return 0;
}
- (void)handleErrors:(int)errorNumber {
NSString *errorText;
switch (errorNumber) {
case 11:
errorText = @"All fields are required";
break;
case 21:
errorText = @"Authentication failed";
break;
case 22:
errorText = @"System login failure";
break;
case 23:
errorText = @"Read-Only user required";
break;
case 24:
errorText = @"Network connection failed";
break;
}
UIAlertView *error = [[UIAlertView alloc] initWithTitle:[[NSString alloc] initWithFormat:@"Error: %D", errorNumber]
message:[[NSString alloc] initWithFormat:@"%@", errorText]
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles: nil];
[error show];
[error release];
}
No comments:
Post a Comment