D
D
DartNikitos2014-03-26 23:13:08
Objective-C
DartNikitos, 2014-03-26 23:13:08

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];

and
- (void) mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error
{
    [[CCDirector sharedDirector] dismissViewControllerAnimated:YES completion:NULL];
}

Just in case. CCDirector - inherited from UIViewController.
If anyone knows what is the reason, please tell me.
Thank you.

Answer the question

In order to leave comments, you need to log in

[[+comments_count]] answer(s)
C
CT4H, 2014-06-15
@CT4H

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 question

Ask a Question

731 491 924 answers to any question