Develop
2014.05.12 21:58
[ios] 언어, 지역, 국가 설정 가져오기
조회 수 269979 댓글 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 ...)
번호 | 분류 | 제목 | 글쓴이 | 날짜 | 조회 수 |
---|---|---|---|---|---|
969 | Develop | [ios] 설정에서 푸시 알림(APNS) on/off 상태 확인 | hooni | 2015.04.28 | 2049 |
968 | Develop | [ios] GPS 이용 상태 확인 | hooni | 2015.04.27 | 1298 |
967 | Develop | [js] jQuery, Javascript 모바일(스마트폰) 판단하는 방법 | hooni | 2015.04.26 | 2454 |
966 | PPT | [ppt] iOS 플라랩#03(2015.04.27) 발표 자료 | hooni | 2015.04.24 | 1066 |
965 | PPT | [ppt] iOS 플라랩#02(2015.03.19) 발표 자료 | hooni | 2015.04.24 | 904 |
964 | Etc | WM미통기 - 10. 조건부확률 | hooni | 2015.04.20 | 710 |
963 | Etc | 수리통계학 : 표본공간과 사상-1 | hooni | 2015.04.20 | 905 |
962 | Etc | EBS [수학영역] 미적분과 통계 기본 - 정규분포의 의미와 특징은? | hooni | 2015.04.20 | 1006 |
961 | Develop | [js] e.stopPropagation() VS e.preventDefault () | hooni | 2015.04.14 | 813 |
960 | Develop | [js] 모바일 스크롤 방지(해제) | hooni | 2015.04.14 | 1593 |
959 | Develop | [js] 스크롤 이벤트 막기 | hooni | 2015.04.14 | 1012 |
958 | Develop | [ios] 앱에서 설정화면 호출하기 | hooni | 2015.04.07 | 750 |