iOS Developer Library

Developer

MFMailComposeViewControllerDelegate Protocol Reference

Options
Deployment Target:

On This Page
Language:

MFMailComposeViewControllerDelegate

Inheritance


Not Applicable

Conforms To


Import Statement


Swift

import MessageUI

Objective-C

@import MessageUI;

Availability


Available in iOS 3.0 and later.

The MFMailComposeViewControllerDelegate protocol defines the method that your delegate must implement to manage the mail composition interface. The method of this protocol notifies your delegate object when the user has finished with the interface and is ready to dismiss it.

Your delegate object is responsible for dismissing the picker when the operation completes. You do this using the dismissModalViewControllerAnimated: method of the parent view controller responsible for displaying the MFMailComposeViewController object’s interface.

  • Tells the delegate that the user wants to dismiss the mail composition view.

    Declaration

    Swift

    optional func mailComposeController(_ controller: MFMailComposeViewController!, didFinishWithResult result: MFMailComposeResult, error error: NSError!)

    Objective-C

    - (void)mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error

    Parameters

    controller

    The view controller object managing the mail composition view.

    result

    The result of the user’s action.

    error

    If an error occurred, this parameter contains an error object with information about the type of failure.

    Discussion

    Your implementation of this method should dismiss the mail composition view. Implementation of this method is optional but expected.

    If the user has opted to send the email created by this interface, that email should be queued in the user’s Mail program by the time this method is called. If an error occurred while queueing the email message, the error parameter contains an error object indicating the type of failure that occurred.

    Import Statement

    Objective-C

    @import MessageUI;

    Swift

    import MessageUI

    Availability

    Available in iOS 3.0 and later.