0

I'm copying phone number from iPhone address book to a text field. In text field it is showing as 1 (234) 567-8901. I want format it to 12345678901.
Any help?

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
jack
  • 73
  • 1
  • 10

1 Answers1

2

You can use stringByReplacingOccurrencesOfString: withString: to remove characters you don't want such as @"(" with @""

EDIT: Better solution.

NSCharacterSet *charSet =[NSCharacterSet characterSetWithCharactersInString:@"()- "];
cleanedPhoneNumber = [phoneNumberString stringByTrimmingCharactersInSet:charSet];  
Jaybit
  • 1,864
  • 1
  • 13
  • 20