首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >MFMailComposeViewController泄露?

MFMailComposeViewController泄露?
EN

Stack Overflow用户
提问于 2012-03-29 04:23:44
回答 1查看 308关注 0票数 2

当我发送电子邮件时,下面的代码会泄漏,我不知道要更改什么。有人在网上说MFMailComposeViewController泄漏了,但令人难以置信的是泄漏从来没有得到修复。

任何想法,以下代码可能有什么问题,或确认MFMailComposeViewController泄漏。

代码语言:javascript
复制
- (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];
}
EN

回答 1

Stack Overflow用户

发布于 2012-03-29 04:54:18

这段代码没有任何问题。如果你在一个应用程序中发现了泄漏,那么我建议你为它提交一个雷达,并详细说明是什么步骤导致了泄漏。

另外,我会将recipients行的设置更改为:

代码语言:javascript
复制
[mailViewController setToRecipients:[NSArray arrayWithObject:@"123@123.com"]];
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/9915102

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档