Use of unresolved identifier 'MFMailComposeCancelled'

Im getting the error "Use of unresolved identifier 'MFMailComposeCancelled'" after setting up a contact forum like below. Has something changed/depreciated that Xcode isnt catching or am I just tired this morning?


import Foundation
import MessageUI

class Contact : UIViewController, MFMailComposeViewControllerDelegate {
    @IBOutlet weak var WOLMenu: UIBarButtonItem!
    @IBOutlet var NameField: UITextField!
    @IBOutlet var EmailField: UITextField!
    @IBOutlet var PhoneField: UITextField!
    @IBOutlet var MessageField: UITextField!




    override func viewDidLoad() {
     
        self.view.addGestureRecognizer(self.revealViewController().panGestureRecognizer())
     
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
    }
    @IBAction func Send(sender: AnyObject) {
        let toRecipients = ["S Jobs @ apple. com"]
     
        let mc: MFMailComposeViewController = MFMailComposeViewController()
     
        mc.mailComposeDelegate = self
     
        mc.setToRecipients(toRecipients)
        mc.setSubject(NameField.text!)
     
        mc.setMessageBody("Name: \(NameField.text!) \n\nEmail: \(EmailField.text!) \n\nPhone: \(PhoneField.text!) \n\nMessage: \(MessageField.text!)", isHTML: false)
     
        self.present(mc, animated: true, completion: nil)
    }

    func mailComposeController(_ controller: MFMailComposeViewController, didFinishWith result: MFMailComposeResult, error: Error?) {
     
        switch result.rawValue {
        case MFMailComposeCancelled.rawValue:
            print("CANCELED")
         
        case MFMailComposeResultFailed.rawValue:
            print("Failed")
         
        case MFMailComposeResultSaved.rawValue:
            print("Saved")
         
        case MFMailComposeResultSent.rawValue:
            print("Sent")
         
        default:
            break
        }
        self.dismiss(animated: true, completion: nil)
    }

    override var prefersStatusBarHidden: Bool {
        return true
    }
}
Answered by TechyGod in 302163022

Found some help on stackoverflow, for those who are looking for an anwser.

https://stackoverflow.com/questions/49520765/mfmailcomposeviewcontroller-giving-multiple-errors

if use the correct code


func mailComposeController(controller: MFMailComposeViewController, didFinishWithResult result: MFMailComposeResult, error: NSError?)


I get this "Instance method 'mailComposeController(controller:didFinishWithResult:error:)' nearly matches optional requirement 'mailComposeController(_:didFinishWith:error:)' of protocol 'MFMailComposeViewControllerDelegate'"

Any help is much appreciated, even if it seems obvious... The more i read elsewhere the more im thinking this is a bug.

The Apple documention code gets corrected... im at a loss, and saddened of the lack of help.


{https://developer.apple.com/documentation/messageui/mfmailcomposeviewcontroller}

Accepted Answer

Found some help on stackoverflow, for those who are looking for an anwser.

https://stackoverflow.com/questions/49520765/mfmailcomposeviewcontroller-giving-multiple-errors

Use of unresolved identifier 'MFMailComposeCancelled'
 
 
Q