일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
Tags
- 윈도우즈7
- 아이폰
- Mobile
- 맥
- c#
- install
- Number
- 퇴사
- Objective-C
- 링크
- 볼링
- WebService
- java
- 오브젝티브C
- iPhone
- 형식
- mac
- 설치
- 아이맥
- 애플
- WSDL
- cagr48com
- screen
- VISTA
- 윈도구
- ObjectiveC
- windows7
- windows
- 7932
- 윈도구7
Archives
- Today
- Total
A colossal Dreamer: GR鐵塔-天生我材
[아이폰:오브젝티브C] 1,000 과 같이 3자리마다 콤마(,) 추가 본문
http://stackoverflow.com/questions/2233824/how-to-add-commas-to-number-every-3-digits-in-objective-c
위의 링크를 보면, NSNumberFormatter 의 헬프를 참조하라고 되어 있다.
NSNumberFormatter 을 사용하면, 간단히 표현할 수 있다.
위의 링크를 보면, NSNumberFormatter 의 헬프를 참조하라고 되어 있다.
NSNumberFormatter 을 사용하면, 간단히 표현할 수 있다.
NSNumberFormatter 은 숫자표현형식의 다양한 부분을 설정할 수 있지만,
간단히 numberStyle 을 NSNumberFormatterDecimalStyle 로 설정하는 것으로 3자리 콤마를 추가할 수 있다.
주) numberSytle을 설정하지 않으면, 그룹핑 및 그룹구분자 표시가 전혀 동작하지 않으니 주의하자.
아래 예제는
NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init];
[numberFormatter setNumberStyle:NSNumberFormatterDecimalStyle];
int nSellPrice = [@"1000" intValue];
NSLog(@"%@원", [numberFormatter stringFromNumber:[NSNumber numberWithInt:nSellPrice]]); [numberFormatter release];
==> 1,000원
'Development > 아이폰' 카테고리의 다른 글
[아이폰:오브젝티브C] 레이블 세로정렬 Top(UILabel vertical Alignment) (0) | 2010.02.25 |
---|---|
[아이폰:오브젝티브C] 앞뒤 공백문자 제거(Trim white space) (0) | 2010.02.19 |
[아이폰:Xcode] Preprocessor Definitions (0) | 2010.02.04 |
[아이팟] 벽돌로부터의 탈출..~~ (0) | 2010.02.02 |
[아이폰:오브젝티브C] 형식 비교하기 (0) | 2010.01.28 |