iphone - How to format double to money format? Eg: 3.234,12 -
i have string input user, string treated have numbers, such as: "3472042"
.
i convert string double value, want formatted money value, like: 3.472,042
just decimalformat in java if helps.
i tried things nsnumberformatter no luck. can give me hand that?
used @ first:
nsstring *string = txtotherpower.text; nscharacterset *removecharset = [nscharacterset charactersetwithcharactersinstring:@"•€£¥./:;@#$%&*(){}[]!?\\-|_=+\"`'~^abcdefghijklmnopqrstvwxyz' '"]; string = [[string componentsseparatedbycharactersinset:removecharset] componentsjoinedbystring:@""];
so acceptable characters comma ","
, numbers. problem if type "2,2,2,2,,,,,1,,2"
won't anything. , messes string/number.
i need formatted money values... ideas?
create nsnumberformatter
, set style nsnumberformattercurrencystyle
or nsnumberformatterdecimalstyle
(or, if styles don't work you, configure setpositiveformat:
, setnegativeformat:
etc.), , convert number string stringfromnumber:
.
see documentation class details.
Comments
Post a Comment