I’m obviously missing something in my code, because any time I try to press “Send” or “Cancel” the app crashes. Also, I have a set subject and torecipient, but if I try to edit them, the app crashes. Any help would be appreciated. Here’s my current code relating to MFMailComposeViewController:
MFMailComposeViewController *controller = [[[MFMailComposeViewController alloc] init] autorelease];
controller.hidesBottomBarWhenPushed = YES;
controller.mailComposeDelegate = self;
[controller setToRecipients:[NSArray arrayWithObject:@"BSCApp@ymail.com"]];
[controller setSubject:@"My Subject"];
if (controller) [self presentModalViewController:controller animated:YES];
[controller release];
and…
- (void)mailComposeController:(MFMailComposeViewController*)controller
didFinishWithResult:(MFMailComposeResult)result
error:(NSError*)error;
{
if (result == MFMailComposeResultSent) {
NSLog(@"It's away!");
}
[self dismissModalViewControllerAnimated:YES];
}
Thanks in advance.
You have
autoreleaseandreleaseon the same instance, so you’re over-releasing it and later when you try to do anything with it, you get a crash for accessing a zombie object.Remove the
autoreleasemessage from first line and it will be fine.