I have the following block of code which works fine in the simulator and on most devices, on some devices however (all on the same iOS version 4.2.1) the app is crashing when it gets to the [mailComposer release]
call, does anyone have any insight on why this would be happening?
MFMailComposeViewController *mailComposer = [[MFMailComposeViewController alloc] init];
mailComposer.mailComposeDelegate = self;
[mailComposer setSubject:[self.webView stringByEvaluatingJavaScriptFromString:@"document.title"]];
[mailComposer setMessageBody:[NSString stringWithFormat:@"Hello, \n\n Here is the link we discussed. \n %@", [self.webView.request URL]] isHTML:NO];
[self presentModalViewController:mailComposer animated:YES];
[mailComposer release];
Ok so I managed to figure out what was causing my issue with the help of my new iPad 2.
The issue was caused by not having any mail accounts configured, simply adding
if ([MFMailComposeViewController canSendMail])
before I create and present the view prevents the crashing, in my else
block I added an UIAlertView
to let the user know they cannot access that feature without first configuring a mail account.