1. Welcome to the new MacRumors forums. See our announcement and read our FAQ

NSError and UIAlertView Problem

Discussion in 'iPhone/iPad Programming' started by newtoiphonesdk, Aug 25, 2010.

  1. macrumors 6502a

    #1
    I am setting up MFMailComposer within app. I want it to have a UIAlertView display the results of sending the email. I have this code installed:
    Code:
    - (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error 
    {	
    	message.hidden = NO;
    	// Notifies users about errors associated with the interface
    	switch (result)
    	{
    		case MFMailComposeResultCancelled:{
    			UIAlertView *cancelled = [[UIAlertView alloc] initWithTitle:@"Results" message:@"Email Was Cancelled" delegate:self cancelButtonTitle:@"Okay" otherButtonTitles:nil];
    			[cancelled show];
    			[cancelled release];}
    			
    		case MFMailComposeResultSaved:{
    			UIAlertView *saved = [[UIAlertView alloc] initWithTitle:@"Results" message:@"Email Draft Saved" delegate:self cancelButtonTitle:@"Okay" otherButtonTitles:nil];
    			[saved show];
    			[saved release];}
    			
    		case MFMailComposeResultSent:{
    			UIAlertView *sent = [[UIAlertView alloc] initWithTitle:@"Results" message:@"Email Sent" delegate:self cancelButtonTitle:@"Okay" otherButtonTitles:nil];
    			[sent show];
    			[sent release];
    		}
    		case MFMailComposeResultFailed:{
    			UIAlertView *failed = [[UIAlertView alloc] initWithTitle:@"Results" message:@"Email Failed To Send, Please Check Internet Connection And Try Again." delegate:self cancelButtonTitle:@"Okay" otherButtonTitles:nil];
    			[failed show];
    			[failed release];
    		}
    	}
    	[self dismissModalViewControllerAnimated:YES];
    }
    
    However, when I debug, no matter what I press, every UIAlertView will pop up. What is the cause of this?
     
  2. macrumors 603

    #2
  3. macrumors newbie

    sherry2009

    #3
    Code:
    - (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error 
    {	
    	message.hidden = NO;
    	// Notifies users about errors associated with the interface
    	switch (result)
    	{
    		case MFMailComposeResultCancelled:{
    			UIAlertView *cancelled = [[UIAlertView alloc] initWithTitle:@"Results" message:@"Email Was Cancelled" delegate:self cancelButtonTitle:@"Okay" otherButtonTitles:nil];
    			[cancelled show];
    			[cancelled release];
                           [COLOR="Red"]break[/COLOR];
    }
    			
    		case MFMailComposeResultSaved:{
    			UIAlertView *saved = [[UIAlertView alloc] initWithTitle:@"Results" message:@"Email Draft Saved" delegate:self cancelButtonTitle:@"Okay" otherButtonTitles:nil];
    			[saved show];
    			[saved release];
                            [COLOR="red"]break[/COLOR];
    }
    			
    		case MFMailComposeResultSent:{
    			UIAlertView *sent = [[UIAlertView alloc] initWithTitle:@"Results" message:@"Email Sent" delegate:self cancelButtonTitle:@"Okay" otherButtonTitles:nil];
    			[sent show];
    			[sent release];
                            [COLOR="red"]break[/COLOR];
    		}
    		case MFMailComposeResultFailed:{
    			UIAlertView *failed = [[UIAlertView alloc] initWithTitle:@"Results" message:@"Email Failed To Send, Please Check Internet Connection And Try Again." delegate:self cancelButtonTitle:@"Okay" otherButtonTitles:nil];
    			[failed show];
    			[failed release];
                            [COLOR="red"]break[/COLOR];
    		}
    	}
    	[self dismissModalViewControllerAnimated:YES];
    }
     

Share This Page