Develop
2014.05.12 21:58
[ios] 언어, 지역, 국가 설정 가져오기
Views 270533 Comment 0
아이폰에 설정된 지역 포맷(언어와 국가 정보)를 가져오려면 NSLocale 클래스를 사용한다.
지역 포맷 가져오기
NSLocale *currentLocale = [NSLocale currentLocale];
언어 설정 보기
NSLocale *currentLocale = [NSLocale currentLocale]; NSString *languageCode = [currentLocale objectForKey:NSLocaleLanguageCode]; // ko (en ...)
국가 설정 보기
NSLocale *currentLocale = [NSLocale currentLocale]; NSString *countryCode = [currentLocale objectForKey:NSLocaleCountryCode]; // KR (US ...)
언어와 국가 한번에 가져오기 (locale identifier)
NSLocale *currentLocale = [NSLocale currentLocale]; NSString *lcid = [currentLocale localeIdentifier]; // ko_KR (en_US ...)
아이폰에 설정된 언어(지역 포맷 아님)를 가져오려면 다음과 같이 할 수 있다.
NSString *preferredLanguageCode = [[NSLocale preferredLanguages] objectAtIndex:0]; // ko (en ...)
또는 NSUserDefaults 클래스를 사용할 수도 있다.
NSUserDefaults *userDefaults = [standardUserDefaults]; NSArray *languages = [userDefaults objectForKey: @"AppleLanguages"]; NSString *preferredLanguageCode = [languages objectAtIndex:0]; // ko (en ...)
No. | Category | Subject | Author | Date | Views |
---|---|---|---|---|---|
193 | Develop | [java] 거스름돈 계산.. swing 사용 | hooni | 2013.04.23 | 9454 |
192 | Develop | [java] 에디터.. swing 사용 | hooni | 2013.04.23 | 6323 |
191 | Develop | [java] 채팅 프로그램.. swing 사용.. | hooni | 2013.04.23 | 8364 |
190 | Develop | [c] 메세지 프로그램 (Server - Agent - Client) | hooni | 2013.04.23 | 6477 |
189 | Develop | [linux] 임베디드 리눅스 (embedded linux) | hooni | 2013.04.23 | 7381 |
188 | Develop | [c] 자료구조 그래프(graph) 소스코드 - 확인해볼 것.. | hooni | 2013.04.23 | 8008 |
187 | Develop | [c] 확인해 볼거.. ㅡ,.ㅡ; | hooni | 2013.04.23 | 7173 |
186 | Develop | [c] 퀵정렬(quick sort) 예제 소스.. | hooni | 2013.04.23 | 7991 |
185 | Develop | [c++] 소켓 프로그래밍 관련 링크.. (퍼올려고 올린거) | hooni | 2013.04.23 | 7056 |
184 | Develop | [c++] WinSock2.0 채팅 프로그램 ㅋㅋ | hooni | 2013.04.23 | 8562 |
183 | Develop | [c] 무선 Radius Server 자료.. | hooni | 2013.04.23 | 7278 |
182 | Develop | [c++] MD5 구현 소스.. 퍼움.. | hooni | 2013.04.23 | 24134 |