Re: How apply a mask (xxx-xxx-xxxx for phone #) to a text field while inputting?
Re: How apply a mask (xxx-xxx-xxxx for phone #) to a text field while inputting?
- Subject: Re: How apply a mask (xxx-xxx-xxxx for phone #) to a text field while inputting?
- From: WT <email@hidden>
- Date: Wed, 24 Jun 2009 13:58:48 +0200
On Jun 23, 2009, at 9:12 AM, Steve Fogel wrote:
Hi, all...
In my iPhone app I'd like to have a text field that duplicates the
behavior of the phone field in the Contacts application, applying a
mask to the field as it's being entered.
So if the user types 2125551212, I'd like the text field to display
(212) 555-1212.
I know about the method
textField:shouldChangeCharactersInRange:replacementString:, which
would enable me to brute force this with lots of code. However, I'd
like to be able to take locale into consideration, so this becomes
non-trivial.
Anyone know of any locale-aware foundation classes that help with
this?
Thx
Steve
I did a little google search just now for 'cocoa phone number
formatter' and found too relevant hits, neither of which appears to be
locale-aware:
http://books.google.com/books?id=AeyX8GqdzPYC&pg=PA394&lpg=PA394&dq=cocoa+phone+number+formatter&source=bl&ots=66bDV_XkNz&sig=le-WM-i36qIwkSwlVzOiJEZtq0Y&hl=en&ei=ng9CSu-DIdPMjAfq5pynBg&sa=X&oi=book_result&ct=result&resnum=4
(tinyurl link, if the above gets chewed: http://preview.tinyurl.com/lvrcbx)
http://www.theflyingjalapenolives.com/2009/05/iphone-code-snippet-phone-number-formatter/
Of course, the best solution would be for Apple to provide a locale-
aware NSPhoneNumberFormatter class. May I suggest that you file a
"feature request" entry?
Wagner
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden