ios - How to use comma method to make calculator -


I am now applying a calculator. In some way, I can show the number to display as NSString but, I want to add a number of commas in the display. I searched the method (comma) for adding numbers, but I'm not sure how to use the method. I would like to change DisplayNumber (without commas) with DisplayNumber (with commas) through the CreateStringAddedCommaFromInt method. How should I solve?

* DisplayNumber, firstNumber, secondNumber int.

  - Show zero (show) = DisplayNumber = firstNumber + secondNumber; LabelTotal.text = [NSString stringWithFormat: @ "% g", DisplayNumber]; } - (NSString *) createStringAddedCommaFromInt: (NSInteger) number {NSNumberFormatter * format = [[NSNumberFormatter alloc] init]; [Format set number number: NSNumberFormatterDecimalStyle]; [Format Set Sooming Separator: @ ","]; [Format set set size: 3]; Return [Format StringFor Object Value: [NSNumber NumberWind: Number]]; }  

In addition to setting the grouping separator, you will see the NSNumberFormatter To use it: NSNumberFormatter * format = [[NSNumberFormatter alloc] init]; format.locale = [NSLokel runs]; // & lt; & Lt; == Do not forget to set locale [Format setNumberStyle: NSNumberFormatterDecimalStyle]; [Format Set Sooming Separator: @ ","]; [Format set set size: 3]; format.uses grouping separator = yes; // & lt; & Lt; == Add this line

This should produce a number with a comma separator.

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -