jack
jack

Reputation: 73

iPhone phone number format NSFormatter

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?

Upvotes: 0

Views: 671

Answers (1)

Jaybit
Jaybit

Reputation: 1864

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];  

Upvotes: 2

Related Questions