PersianBlue PersianBlue - 4 months ago 10
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'


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() {
// Do any additional setup after loading the view, typically from a nib.

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

Can someone please help me?


Add the MessageUI Framework,

import UIKit
import MessageUI

class ViewController: UIViewController, MFMessageComposeViewControllerDelegate {


hope its helpful