views:

242

answers:

2

I want to be able to replicate what the AddressBook does in Contacts app and Phone app when entering a phone number in both the keypad on the Phone app and adding a contact.

I know I could do it checking each time a character is entered into the UITextField but there are hundreds of number formats out there and it would take me forever to code it all.

Is there any API to this i can use or any known open source code i could use at all?

+1  A: 

You hit the nail on the head - check the characters typed each time.

AlBlue
hmm so no list on the internet or anything to help me?
DotSlashSlash
A: 

The UIPhoneFormats.plist contains predefined phone formats for each locale. You'll need to write code to subsitute your input string into these string masks. I had to do something similar, and I shared the results I got here: http://the-lost-beauty.blogspot.com/2010/01/locale-sensitive-phone-number.html

ahmadabdolkader