title: Sending an SMS with Swift, remember phone number
body: <p>I'm working on an app where you can send an sms to someone within the app. This is what I've found so far. I would like to remember the phone number once it has been entered for the future, though the user has the ability to change it whenever they want to. Any ideas?</p>
  
  <pre><code>import UIKit
  import MessageUI
  
  class ViewController: UIViewController, MFMessageComposeViewControllerDelegate {
  
  @IBOutlet weak var phoneNumber: UITextField!
  
  override func viewDidLoad() {
      super.viewDidLoad()
  }
  
  @IBAction func sendText(sender: UIButton) {
      if (MFMessageComposeViewController.canSendText()) {
          let controller = MFMessageComposeViewController()
          controller.body = "Message Body"
          controller.recipients = [phoneNumber.text]
          controller.messageComposeDelegate = self
          self.presentViewController(controller, animated: true, completion: nil)
      }
  }
  
  func messageComposeViewController(controller: MFMessageComposeViewController!, didFinishWithResult result: MessageComposeResult) {
      //... handle sms screen actions
      self.dismissViewControllerAnimated(true, completion: nil)
  }
  
  override func viewWillDisappear(animated: Bool) {
      self.navigationController?.navigationBarHidden = false
  }
  }
  </code></pre>