Take the 2-minute tour ×

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 
                          cancelButtonTitle: @"OK"
                          otherButtonTitles: nil];
    [alert show];



- (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?

share|improve this question
I would recommend really understanding the delegate design pattern and not just fixing this problem. It's one of the most useful things for you to understand. developer.apple.com/library/mac/#documentation/cocoa/conceptual/… –  rooster117 Oct 31 '12 at 22:25

2 Answers 2

up vote 3 down vote accepted

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.

share|improve this answer
I have edited my question to show the pertinent code. Delegates are one of my weakest areas of expertise; therefore, I'm not sure what you are referring to. Could you please elaborate? –  spokane-dude Oct 31 '12 at 22:09
I gave you the change for the @interface line. And when you create the alert view, pass in self for the parameter to delegate: instead of nil. –  rmaddy Oct 31 '12 at 22:37
Got it... thank you... I appreciate your time... –  spokane-dude Oct 31 '12 at 22:38
Don't forget to accept an answer. –  rmaddy Oct 31 '12 at 22:39

Your delegate looks like nil as per your code 'delegate:nil' in the question. You need to change it to 'delegate:self'.

share|improve this answer

Your Answer


