Develop
2014.05.12 21:58
[ios] 언어, 지역, 국가 설정 가져오기
조회 수 269600 댓글 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 ...)
번호 | 분류 | 제목 | 글쓴이 | 날짜 | 조회 수 |
---|---|---|---|---|---|
285 | System/OS | [mac] 컨텍스트(Context) 메뉴 "다음으로 열기" 내용 정리 | hooni | 2013.07.10 | 18797 |
284 | System/OS | [mac] 패키지 매니저, MacPort | hooni | 2015.01.03 | 967 |
283 | System/OS | [mac][추천 무료앱] 구름 입력기 - 국내 맥 사용자를 위한 한글 대안 입력기 1 | hooni | 2015.01.04 | 2145 |
282 | Develop | [matlab] ZigZag-Scanning (2-D Array) | hooni | 2016.10.15 | 1978 |
281 | Develop | [matlab] 정보은닉 스테가노그래피(Steganography) 수업 | hooni | 2016.10.03 | 676 |
280 | Develop | [maven] Mac OS에 메이븐(maven) 설치하기 | hooni | 2015.01.21 | 1102 |
279 | System/OS | [ms-sql] 서브스트링(substring), 프로시저(SP) 작성 예제 | hooni | 2013.04.23 | 41296 |
278 | System/OS | [ms-sql] 프로시져 예제.. | hooni | 2013.04.23 | 13406 |
277 | Database | [mysql] CPU 점유율이 높을 때 확인할 내용 | hooni | 2015.08.26 | 6643 |
276 | Database | [mysql] DB->Text, Text->DB 변환 | hooni | 2003.04.23 | 12129 |
275 | Database | [mysql] ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement. | hooni | 2017.12.15 | 1193 |
274 | Database | [mysql] error while loading shared libraries: libmysqlclient.so.10: | hooni | 2003.04.23 | 12663 |