title: UitextFiled with first letter must 0 and format will be like (0) 1234 56789
body: <p>I am using phone number texfield, now i am using this format for texfield (#) #### #####, now issue is that i want first character 0 as compulsary, like this (0) 1234 56789, so user enter whatever first character must be typed 0, its not duplicate quesion number format is different</p>
  
  <p>here is my code but its not working</p>
  
  <pre><code>func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -&gt; Bool {
      var oldText = (textField.text! as NSString).replacingCharacters(in: range, with: string)
      if oldText.count &gt; 15 { return false }
      oldText = oldText.replacingOccurrences(of: "(0)", with: "").replacingOccurrences(of: " ", with: "")
      if !oldText.isEmpty {
          oldText = "(0)" + oldText
      }
      let newText = String(stride(from: 0, to: oldText.count, by: 3).map {
          let sIndex = String.Index(encodedOffset: $0)
          let eIndex = oldText.index(sIndex, offsetBy: 3, limitedBy: oldText.endIndex) ?? oldText.endIndex
          return String(oldText[sIndex..&lt;eIndex])
          }.joined(separator: " "))
      textField.text = newText
      return false
  }
  </code></pre>