Go Back   MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Aug 25, 2010, 10:56 AM   #1
newtoiphonesdk
macrumors 6502a
 
Join Date: Jul 2010
NSError and UIAlertView Problem

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?
newtoiphonesdk is offline   0 Reply With Quote
Old Aug 25, 2010, 11:37 AM   #2
chown33
macrumors 603
 
Join Date: Aug 2009
You have no break statements.

Read a C or Objective-C language reference. Learn about switch and how case falls through without a break.

Overview article:
http://en.wikipedia.org/wiki/Switch_statement
chown33 is offline   0 Reply With Quote
Old Aug 25, 2010, 10:07 PM   #3
sherry2009
macrumors newbie
 
Join Date: Dec 2009
Send a message via ICQ to sherry2009 Send a message via MSN to sherry2009 Send a message via Skype™ to sherry2009
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];
                       break;
}
			
		case MFMailComposeResultSaved:{
			UIAlertView *saved = [[UIAlertView alloc] initWithTitle:@"Results" message:@"Email Draft Saved" delegate:self cancelButtonTitle:@"Okay" otherButtonTitles:nil];
			[saved show];
			[saved release];
                        break;
}
			
		case MFMailComposeResultSent:{
			UIAlertView *sent = [[UIAlertView alloc] initWithTitle:@"Results" message:@"Email Sent" delegate:self cancelButtonTitle:@"Okay" otherButtonTitles:nil];
			[sent show];
			[sent release];
                        break;
		}
		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];
                        break;
		}
	}
	[self dismissModalViewControllerAnimated:YES];
}
__________________
Dare and the world always yields. If it beats you sometimes, dare it again and again and it will succumb.
sherry2009 is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
Resolved: UIALertView Restore after applicationDidEnterBackground IDMah iPhone/iPad Programming 8 Apr 22, 2014 02:16 PM
Resolved: UIAlertView Unwind Segue Blakeasd iPhone/iPad Programming 8 Mar 21, 2014 02:04 PM
Undeclared identifier in UIAlertView Kapthehat iPhone/iPad Programming 2 Sep 2, 2013 06:19 AM
Check for change UIAlertview ackleymi iPhone/iPad Programming 1 Aug 4, 2012 02:15 AM

Forum Jump

All times are GMT -5. The time now is 05:51 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC