I have a string like this in Swift:
var stringts:String = \"3022513240\"
If I want to change it to string to something like this: \"(
To Display 10 digit phone number into USA Number format (###) ###-#### SWIFT 3
func arrangeUSFormat(strPhone : String)-> String {
var strUpdated = strPhone
if strPhone.characters.count == 10 {
strUpdated.insert("(", at: strUpdated.startIndex)
strUpdated.insert(")", at: strUpdated.index(strUpdated.startIndex, offsetBy: 4))
strUpdated.insert(" ", at: strUpdated.index(strUpdated.startIndex, offsetBy: 5))
strUpdated.insert("-", at: strUpdated.index(strUpdated.startIndex, offsetBy: 9))
}
return strUpdated
}