In the YourFunctions.h file of the new class:
- (void) showAlert:(int)errorNumber;
In the YourFunctions.m file of the new class:
- (void) showAlert:(int)errorNumber {
UIAlertView *error = [[UIAlertView alloc] initWithTitle:[[NSString alloc] initWithFormat:@"Error: %D", errorNumber]
message:[[NSString alloc] initWithFormat:@"This is an error"]
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles: nil];
[error show];
[error release];
}
In the YourView.m file you are calling this new method from:
#import "YourFunctions.h"
// As a test I attached a button to this action.
- (IBAction)showAnAlert {
int errorNumber = 22;
YourFunctions *yourFunctions = [[YourFunctions alloc] init];
[yourFunctions showAlert:errorNumber];
}
No comments:
Post a Comment