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 (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to