Code given below will help you to format mobile number like (XXX)-(XXX)-XXXX you just need to call this method in your shouldChangeCharactersIn method like this, func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool { // phonenumber write in specific formate if …