Reputation: 4974
I have an iPhone app which sends an email. If the "To:" address is not set, I display an Alert (UIAlertView). At the present time, I do not check for the user tapping OK, I just go on my merry way! :D
I am getting the following error when tapping OK on the Alert:
wait_fences: failed to receive reply: 10004003
I believe it's because I don't handle the tapping of OK and it's still showing when the app is doing something else. So, after doing some research on SO and Google, it appears I have to have this:
- (void) Alert: (NSString *) title andData: (NSString *) errorMsg {
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle: title
message: errorMsg
delegate:nil
cancelButtonTitle: @"OK"
otherButtonTitles: nil];
[alert show];
return;
}
- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex
{
NSLog(@"button was pressed");
}
My problem is that I can't figure out how to set up the delegate for this. I already have a delegate:
@interface ReportViewController : UIViewController <UIWebViewDelegate> {
How do I set the delegate so the tap of the OK button is handled, thus removing the error?
Upvotes: 2
Views: 230
Reputation:
Your delegate looks like nil as per your code 'delegate:nil'
in the question. You need to change it to 'delegate:self'
.
Upvotes: 1
Reputation: 318774
Inside the angle brackets, you can provide a comma-separated list of protocols.
@interface ReportViewController : UIViewController <UIWebViewDelegate, UIAlertViewDelegate> {
Now you can implement both sets of methods. And don't forget to set the alert view's delegate to self
.
Upvotes: 4