2010년 07월 25일
cocoa에서 숫자 3자리마다 컴마 찍는 방법
NSNumberFormatter라는 멋진 넘이 있네요.
// formatter를 미리 만들어 놓고.. 재사용 ㄱㄱ~
NSNumberFormatter *frmtr = [[NSNumberFormatter alloc] init];
[frmtr setGroupingSize:3];
[frmtr setGroupingSeparator:@","];
[frmtr setUsesGroupingSeparator:YES];
// 실제로 숫자 --> 컴마 문자열로 변환할 때
int number = 10000000;
NSString* commaString = [frmtr stringFromNumber:[NSNumber numberWithInt:number]];
// commaString == @"10,000,000";
출처 : http://www.tech-recipes.com/rx/5460/cocoa-convert-number-to-comma-separated-nsstring/
# by | 2010/07/25 20:48 | 개발 | 트랙백 | 덧글(0)





☞ 내 이글루에 이 글과 관련된 글 쓰기 (트랙백 보내기) [도움말]