title: replacingOccurrences(of: " ", with: "") Not Working
body: <p>I have a text field where a user enters their phone number. When they hit the 'continue' button, the text in the text field is assigned to a global variable called phoneNumber. I then proceed to clean the string of any non-integer values such as '-', ')', and '+'. When I try to delete spaces it doesn't always work. I realized it only doesn't work when I autofill my phone number. Are spaces in autofill phone numbers different than spaces from our keyboards?</p>
  
  <p>Can someone help me figure out what's happening here or if there's a better way to do this?</p>
  
  <pre><code>class LoginViewController: UIViewController {
  
  @IBOutlet weak var phoneNumberTextField: UITextField!
  var phoneNumber = ""
  
  @IBAction func continueButton(_ sender: Any) {
  
      self.phoneNumber = phoneNumberTextField.text!
  
      for _ in 0...phoneNumber.count {
      self.phoneNumber = self.phoneNumber.replacingOccurrences(of: " ", with: "")
      self.phoneNumber = self.phoneNumber.replacingOccurrences(of: "-", with: "")
      self.phoneNumber = self.phoneNumber.replacingOccurrences(of: "(", with: "")
      self.phoneNumber = self.phoneNumber.replacingOccurrences(of: ")", with: "")
      }
  
      checkCount(phoneNumber: self.phoneNumber)
  }
  
  func checkCount(phoneNumber : String) {
          if phoneNumber.count == 11 {
              self.phoneNumber = "+" + phoneNumber
          }
          else if phoneNumber.count == 10 {
              self.phoneNumber = "+1" + phoneNumber
          }
  }
  }
  </code></pre>