PersianBlue PersianBlue - 5 months ago 24
Swift Question

use of undeclared type 'MFMessageComposeViewControllerDelegate swift'

i am trying to implement sending a text message using the MFMessageComposeViewController object. But when i am trying to declare the MFMessageComposeViewControllerDelegate protocol. In ViewController.swift i get the following error : use of undeclared type 'MFMessageComposeViewControllerDelegate swift'

ViewController.swift:

class ViewController: UIViewController, MFMessageComposeViewControllerDelegate {

@IBAction func sendMessage(sender: AnyObject) {
var messageVC = MFMessageComposeViewController()

messageVC.body = "Enter a message";
messageVC.recipients = ["Enter tel-nr"]
messageVC.messageComposeDelegate = self;

self.presentViewController(messageVC, animated: false, completion: nil)
}


override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}

override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}


Can someone please help me?

Answer

Add the MessageUI Framework,

import UIKit
import MessageUI

class ViewController: UIViewController, MFMessageComposeViewControllerDelegate {

}

hope its helpful