当我发送电子邮件时,下面的代码会泄漏,我不知道要更改什么。有人在网上说MFMailComposeViewController泄漏了,但令人难以置信的是泄漏从来没有得到修复。
任何想法,以下代码可能有什么问题,或确认MFMailComposeViewController泄漏。
- (void) email {
if ([MFMailComposeViewController canSendMail]) {
MFMailComposeViewController *mailViewController = [[MFMailComposeViewController alloc] init];
mailViewController.mailComposeDelegate = self;
[mailViewController setToRecipients:[[[NSMutableArray alloc] initWithObjects:@"123@123.com", nil] autorelease]];
[mailViewController setSubject:@"Contact us"];
[self presentModalViewController:mailViewController animated:YES];
[mailViewController release];
} else {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Cannot send email"
message:@"Please check your email setting"
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
[alert release];
}
}
- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error {
[self dismissModalViewControllerAnimated:YES];
}发布于 2012-03-29 04:54:18
这段代码没有任何问题。如果你在一个应用程序中发现了泄漏,那么我建议你为它提交一个雷达,并详细说明是什么步骤导致了泄漏。
另外,我会将recipients行的设置更改为:
[mailViewController setToRecipients:[NSArray arrayWithObject:@"123@123.com"]];https://stackoverflow.com/questions/9915102
复制相似问题