Reputation: 1105
I have a series of strings that come in, that are essentially dollar values, but they are unformatted.
So for example they look like this:
I want to format these as a currency, like this:
Ideally, I'd like it to be localized as well. I know I can use NSNumberFormatter to achieve this, but that would involve me converting these strings to NSNumbers and the formatting them with my formatter, only to convert them back to strings from the NSNumber that has been formatted.
Is there a way to skip the number conversion altogether and just format the string?
Upvotes: 1
Views: 855
Reputation: 32681
Yes you should convert your (unformatted) strings to numbers and then use NSNumberFormatter to strings.
Upvotes: 2
Reputation: 16472
From the documentation here it doesn't look like it.
EDIT
Similar Question was also asked:
Easiest way to convert a NSString to its currency equivalent in Cocoa
Upvotes: 3