2

Help on this would be much appreciated.

I would like to send an SMS message from within an app in iOS.

In Xcode, I have done the following:

Added a reference in Link Binary With Library:

MessageUI.framework

In ViewController.swift I have added the import:

import MessageUI

However, when I try to add the delegate ...

class ViewController: UIViewController, MFMessageComposeViewControllerDelegate {

    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.
    }


}

I get this error:

Type 'ViewController' does not conform to protocol 'MFMessageComposeViewControllerDelegate'


Update

Solved by following Antonio's advice. I added this:

func messageComposeViewController(controller: MFMessageComposeViewController!, didFinishWithResult result: MessageComposeResult) {
}
Sparked
  • 844
  • 10
  • 25

1 Answers1

8

That means you have not implemented the methods defined in the protocol. Look at the documentation to know what you have to implement.

In this case, it's just a method:

func messageComposeViewController(_ controller: MFMessageComposeViewController!, didFinishWithResult result: MessageComposeResult)
Antonio
  • 71,651
  • 11
  • 148
  • 165
  • Thank you. Question amended to include answer. – Sparked Nov 17 '14 at 22:47
  • Glad it worked. Note that there's no need to update your answer to include the solution, as long as you mark an answer as accepted... of course you can do if you like, but the accepted answer is always clearly visible. – Antonio Nov 17 '14 at 23:32