Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
thread Thread Starter Forum Replies Last Post
Problems, problems and more problems tribaltek Mac OS X 10.7 Lion 9 Jul 30, 2011 10:44 AM
Erase and Install Problem, Desperate for help! imrealldum iMac 5 Mar 13, 2011 02:02 PM
Problems, Problems and more problems! Macdude2010 iPad 7 Mar 12, 2011 12:42 AM
UndoManager Alert Followed By UIAlertView Problem Darkroom iPhone/iPad Programming 23 Sep 12, 2009 08:42 AM
Problems with iPhone... updating, and battery problems afromanbob iPhone Tips, Help and Troubleshooting 2 Aug 17, 2007 02:32 AM


All times are GMT -5. The time now is 02:54 AM.

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

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