Answer the question
In order to leave comments, you need to log in
Why is memory leaking when using MFMailComposeViewController?
Hello, such a problem:
When using MFMailComposeViewController after clicking "Cancel" in a modal dialog with a letter, some amount of memory is allocated and is not released afterwards. If you repeat this action, the same thing happens (memory continues to be allocated).
I use this code
MFMailComposeViewController *mc = [[MFMailComposeViewController alloc] init];
mc.mailComposeDelegate = self;
[mc setSubject:emailTitle];
[mc setMessageBody:messageBody isHTML:YES];
[[CCDirector sharedDirector] presentViewController:mc animated:YES completion:nil];
[mc release];
- (void) mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error
{
[[CCDirector sharedDirector] dismissViewControllerAnimated:YES completion:NULL];
}
Answer the question
In order to leave comments, you need to log in
Enable ARC in the project settings and delete the line [mc release];
(You will have to delete the [.. release] lines in the entire project), or free up memory in the didFinishWithResult method
PS When using the UIViewController singleton, problems may arise. Read about MVC and obj-c patterns
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question