숫자에 쉼표 (comma)를 넣고 싶은 경우 아래와 같은 코드를 구현하면 된다.
사용법
- NSString result = [StringUtils getInsertedCommaString:123456789];
결과값
- 123,456,789
+ (NSString *)getInsertedCommaString:(int)intValue {
NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init];
[formatter setNumberStyle:NSNumberFormatterDecimalStyle];
return [formatter stringFromNumber:[NSNumber numberWithInt:intValue]];
}
'Development > iOS' 카테고리의 다른 글
[iOS] The app delegate must implement the window property if it wants to use a main storyboard file. (0) | 2020.02.16 |
---|---|
[iOS] 앱 이름 변경 (0) | 2020.02.16 |
[iOS] iOS 13에서 dark mode 미지원 (0) | 2020.02.15 |