I have to format input string as phone number.For i am using

```
(BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string  {
NSUInteger newLength = [textField.text length] + [string length] - range.length;
NSCharacterSet *cs = [[NSCharacterSet characterSetWithCharactersInString:NUMBERS_ONLY] invertedSet];
NSString *filtered = [[string componentsSeparatedByCharactersInSet:cs] componentsJoinedByString:@""];

   if (string.length==3||string.length==7) {
    filtered =[filtered  stringByAppendingString:@"-"];
}
return (([string isEqualToString:filtered])&&(newLength <= CHARACTER_LIMIT));
}

```

here

```
  #define NUMBERS_ONLY @"1234567890-"
  #define CHARACTER_LIMIT 12

```

but its not editing back.

Please give some ideas