NSNumberFormatter with comma decimal separator

后端 未结 5 1742
轻奢々
轻奢々 2020-12-03 13:30

I tried to convert an NSString like \"12000.54\" into \"12.000,54\". I wrote an NSNumberFormatter instance.

NSNumberFormatter *formatter = [[[NSNumberFormat         


        
5条回答
  •  星月不相逢
    2020-12-03 14:36

    The simplest solution I recently found is:

    NSString *localizedString = [NSString localizedStringWithFormat:@"%@", @1234567];
    

    Also works with ints:

    NSString *localizedString = [NSString localizedStringWithFormat:@"%d", 1234567];
    

    Verified in Xcode 6 playground. But docs say this function has always existed.

提交回复
热议问题