This is probably a stupid question but anyway.
开发者_如何学JAVAI wan the number I set on my label to be formated nicely like this 20,000,000 . How do I do this ?
For now I've set the number of decimal points to 0 so I just get the whole number without any places.
[NSString stringWithFormat:@"%.0f", slider.value];
you can use the following formatter:
-(void)setCurrencyFormat
{
NSNumberFormatter *CurrencyFormat = [[NSNumberFormatter alloc] init];
[CurrencyFormat setNumberStyle:NSNumberFormatterCurrencyStyle];
label.text= [CurrencyFormat stringFromNumber:[NSNumber numberWithDouble:billAmountInDouble]];
NSString *st1=[NSString stringWithFormat:@"%@",[CurrencyFormat stringFromNumber:[NSNumber numberWithDouble:individualTaxInDouble]]];
label.text=st1;
}
Check out the docs for NSNumberFormatter - you can do pretty much everything with that.
精彩评论