Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

newtoiphonesdk

macrumors 6502a
Original poster
Jul 30, 2010
567
2
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?
 

sherry2009

macrumors newbie
Dec 14, 2009
12
0
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];
}
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.