On Wed, Sep 28, 2011 at 3:50 PM, Philip McIntosh
<ndpmcint...@earthlink.net> wrote:
>> user input builds up a string in the UITextView
>
> Yes and I want the grouping symbols and decimal separator to show up as the 
> string is built up.

Okay, I understand now.

As the user is entering text, they are building a string of their
input. This is not necessarily the same string that you want to
display to them; you'd like to prettify their input.

I think you should store the user's input separately from the string
being displayed in the UITextView.

User presses a key:
  userInputString = [userInputString stringByAppendingString:pressedKey]
  userInputNumber = [numberFormatter numberFromString:userInputString]
  formattedUserInput = [numberFormatter stringFromNumber:userInputNumber]
  textView.text = formattedUserInput

Then when the user presses Return (or an operator key or whatever
signifies that they're done entering their number), remember the
userInputNumber and discard the userInputString.

> The locale issue is one I am not exactly clear on. If I instantiate a 
> formatter with explicit settings for what grouping and separator symbols I 
> want used, won't that override any locale settings that the OS would attempt 
> to enforce by default? Here's why I want to do that. Let's say the user is 
> from , Oh I don't know--Albania--and has been looking at numbers formatted 
> like 23.456.781,30042 all her life. Shouldn't she be given the option of 
> continuing to look at numbers that way no matter where in the world she is 
> and no matter what locale her device is set to? I think so.

The user indicates this preference by changing their locale using the
Settings app. This setting should apply to all applications.

Sometimes it makes sense for your app to allow the user to override
their locale settings. For example, programmers might need their
decimal numbers to have no grouping separators and using "." for the
decimal separator. Apps that cater to programmers might offer the
option to override the locale and display numbers in this format. But
designers shouldn't make this decision lightly. There's a lot to be
said for having a phone that just works the way you expect it to.

--Kyle Sluder
_______________________________________________

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