I'm still learning Objective-c and Iphone Dev so I'm willing to take instruction. I was wondering if this is the best way to achive a helper function that displays an alertview. Obviously in my code there are various places (report errors, bad data etc) where I wish to display an alert to my user. Rather than create an AlertView object show and release it every time I wish to do that I created a helper function as below
- (void)displayAlertWithTitle:(NSString *)title Message:(NSString *)message
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:title
message:message
delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
[alert release];
}
This is what i would do anywhere else just wondering if thats the done thing in Objective-c?
So the next question is, if I want to be able to use this function anywhere in my app, where should I store it, AppDelegate? Singleton Class? or a Category of NSString?