Develop
2014.05.12 21:58
[ios] 언어, 지역, 국가 설정 가져오기
Views 272047 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 | [ios] 아이폰에서 진동(Vibrate) 기능 추가하기 | hooni | 2014.04.18 | 3539 |
192 | Develop | [js] Array.splice() 설명 | hooni | 2014.04.24 | 3069 |
191 | Develop | [ios] iOS 의 인앱구매 소개 | hooni | 2014.04.29 | 3902 |
190 | Develop | [ios] 커스텀 폰트 사용하기 (Custom Fonts) | hooni | 2014.04.30 | 3194 |
189 | Develop | [ios] NSString URL Encode/Decode (인코딩/디코딩) | hooni | 2014.05.02 | 3497 |
188 | Develop | [ios] 애플 앱스토어 IDFA 리뷰 정책 변경 안내 | hooni | 2014.05.07 | 4251 |
187 | Develop | [ios] 앱딜리게이트 라이프사이클 (AppDelegate Lifecycle) | hooni | 2014.05.09 | 4539 |
186 | Develop | [ios] 앱 딜리게이트 얻어오기. (AppDelegate) | hooni | 2014.05.10 | 3409 |
185 | Develop | [ios] URL 파라미터 파싱~ | hooni | 2014.05.12 | 3742 |
» | Develop | [ios] 언어, 지역, 국가 설정 가져오기 | hooni | 2014.05.12 | 272047 |
183 | Develop | [ios] 아이폰 GPS 사용하기 | hooni | 2014.05.24 | 4054 |
182 | Develop | [ios] iOS에서 디바이스 종류 알아오기 | hooni | 2014.05.24 | 3762 |