title: MFMessageComposeViewController Initialization in Swift
body: <p>I am currently developing an app where I would like to be able to send SMS messages to confirm the user has the number they are sending from.  Then I do some back end work and query the server to see if the number has been validated.</p>
  
  <p>The only issue is that I am unable to send the SMS.  The only tutorials and documentation online from what I can find is Objective-C.</p>
  
  <p>I have copied it to the best of my ability, however there is one portion that I cannot find a Swift equivalent too.  The "init".</p>
  
  <pre><code>func messageComposeViewController(controller: MFMessageComposeViewController!, didFinishWithResult result: MessageComposeResult) {
  
      if (result.value == MessageComposeResultCancelled.value) {
          NSLog("Message was cancelled.");
      }
      else if (result.value == MessageComposeResultFailed.value) {
          var warningAlert : UIAlertView = UIAlertView.alloc();
          warningAlert.title = "Error";
          warningAlert.message = "Failed to send SMS!";
          warningAlert.delegate = nil;
          warningAlert.show();
          NSLog("Message failed.");
      } else {
          NSLog("Message was sent.");
      }
      self.dismissViewControllerAnimated(true, completion: nil);
  }
  
  func showSMS() {
      if (!MFMessageComposeViewController.canSendText()) {
          var warningAlert : UIAlertView = UIAlertView.alloc();
          warningAlert.title = "Error";
          warningAlert.message = "Your device does not support SMS.";
          warningAlert.delegate = nil;
          warningAlert.show();
          return;
      }
  
      var recipients : NSArray = ["1234567890"];
      var message : NSString = "Message.";
  
  
      // This is the problem line I think....
      let messageController : MFMessageComposeViewController = MFMessageComposeViewController.alloc();
  
      /* In Objective-C it is: */
      // MFMessageComposeViewController *messageController = [[MFMessageComposeViewController alloc] init];
  
      // I have also tried this...
      let messageC : MFMessageComposeViewController! = MFMessageComposeViewController();
  
  
      messageController.messageComposeDelegate = self;
      messageController.recipients = recipients;
      messageController.body = message;
  
      self.presentViewController(messageController, animated: true, completion: nil);
  }
  </code></pre>
  
  <p>I believe the issue is that when I run this the MFMessageComposeViewController is not fully instantiated.  Therefore when it hits this code, instead of opening a message dialog the screen just turns black.  I found that this is the issue when the same line is not init'ed in Objective-C.</p>
  
  <p>Thanks in advance for the help.</p>