ios - NSNumberFormatterCurrencyStyle Driving me insane -
i'm trying currency calculator work, , i've stumbled accross problem not know how solve.
the problem when type textfield can type on 100.20, problem arises when try using buttons.
whole numbers work fine click on dot button put's dot after 100.20 end 100.20. , whatever click after it.
if don't use nsnumberformatter works fine well.
here code snippets :
-(ibaction)buttondigitpressed:(id)sender { mainnumber = 100.20; nsnumberformatter *numberformatter = [[nsnumberformatter alloc] init]; [numberformatter setnumberstyle: nsnumberformattercurrencystyle]; mainfield.stringvalue = [numberformatter stringfromnumber:[nsnumber numberwithfloat: mainnumber]]; } if(!userinthemiddleofenteringdecimal) { userinthemiddleofenteringdecimal = yes; mainfield.stringvalue= [mainfield.stringvalue stringbyappendingstring:@"."]; }
Comments
Post a Comment