I used this code but the issue I am having is it does not work if texfield is empty (index out of bounds) and the other issue if the user does not change the phonenumber and hit Save button it will execute the code again and insert the "((" and "--".
Any ideas about what I can do?
var stringts: NSMutableString = self.ts.text
stringts.insertString("(", atIndex: 0)
stringts.insertString(")", atIndex: 4)
stringts.insertString("-", atIndex: 5)
stringts.insertString("-", atIndex: 9)
self.ts.text = stringts