60863

Xcode - Cannot Adopt Protocol

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'

<hr>

<strong>Update</strong>

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

func messageComposeViewController(controller: MFMessageComposeViewController!, didFinishWithResult result: MessageComposeResult) { }

Answer1:

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)

Recommend

  • updatesearchresultsforsearchcontroller not called
  • windowScriptObject method not found on Objective-C code
  • Printing input from TextField to a Label in Xcode with Swift
  • Change border corlor of NSTableView
  • Animate a CAShapeLayer's subclass custom property based on the path property
  • Listview - list item selection and initial setting (custom made items)
  • redirect user after update in class based view in django
  • No such module 'Parse' following Parse iOS Swift Quickstart guide
  • Retrieving a double from a JTextArea while solving for X
  • MRO with multiple inheritance in python
  • Extending the Django 1.11 User Model
  • Fully customized Python Help Usage
  • Swift Initialization Rule Confusion
  • How to upload specific List image using click on Upload button
  • How can we prepend rows to a react native list-view?
  • Blackberry 6: how to detect a long click on track pad?
  • Creating Java object from class name with constructor, which contains parameters [duplicate]
  • how to avoid repetitive constructor in children
  • how to save the state in userdefaults of accessory checkmark-iphone
  • MonoTouch: How to download pdf incrementally as indicated in the Apple slides “Building Newsstand Ap
  • Deleting and Updating values from a cusrsor adapter
  • swift auto completion not working in Xcode6-Beta
  • Possible to stop flickering java tooltip in heavyweight mode?
  • Cassandra Data Model
  • Getting 'uninitialized constant' error when using delegate in belongs_to in model
  • Return words with double consecutive letters
  • Cannot Parse HTML Data Using Android / JSOUP
  • Python: how to group similar lists together in a list of lists?
  • Suggestions to manage Login/Logout transitions
  • Angular 2 constructor injection vs direct access
  • Getting Messege Twice Using IMvxMessenger
  • Java static initializers and reflection
  • Android Google Maps API OnLocationChanged only called once
  • unknown Exception android
  • Busy indicator not showing up in wpf window [duplicate]
  • Observable and ngFor in Angular 2
  • UserPrincipal.Current returns apppool on IIS
  • Unable to use reactive element in my shiny app
  • Python/Django TangoWithDjango Models and Databases