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
}
}
Found some help on stackoverflow, for those who are looking for an anwser.
https://stackoverflow.com/questions/49520765/mfmailcomposeviewcontroller-giving-multiple-errors