Develop
2014.05.12 21:58
[ios] 언어, 지역, 국가 설정 가져오기
조회 수 269920 댓글 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 ...)
번호 | 분류 | 제목 | 글쓴이 | 날짜 | 조회 수 |
---|---|---|---|---|---|
193 | Develop | [api] 인스타그램에서 최신 이미지 가져오기 (Using Instagram API) 20 | hooni | 2018.04.05 | 12390 |
192 | Develop | [php] php5.3부터는 eregi()대신 preg_match()를 사용 | hooni | 2013.11.18 | 12477 |
191 | Develop | [ios] 네트워크 인디케이터(NetworkActivityIndicator) 작동 | hooni | 2014.01.24 | 12493 |
190 | Develop | [c] flooding 알고리즘 미로 찾기(도스용) 소스코드 9 | hooni | 2003.04.23 | 12515 |
189 | Develop | [c++] Win32 API 기본 출력인 MessageBox() 함수 사용 예제.. | hooni | 2013.04.23 | 12643 |
188 | Develop | [html] HTML5 튜토리얼 링크 ㅋㅋ | hooni | 2013.04.23 | 12814 |
187 | Develop | [doc] UI개발시 유용한 소프트웨어 (개발 및 디버깅 툴) | hooni | 2013.04.23 | 12911 |
186 | Develop | [c] 다중연결 서버 만들기 #1 - fork() 사용 | hooni | 2013.04.23 | 12919 |
185 | Develop | [js] 자바스크립트의 클로저 (JavaScript's Closure) | hooni | 2013.05.15 | 12979 |
184 | Develop | [php] 심플한 게시판 ㅋㅋ 1 | hooni | 2013.04.23 | 12993 |
183 | Develop | [js] AngularJS를 소개합니다. | hooni | 2014.01.06 | 13017 |
182 | Develop | [html] 캐쉬된 웹페이지 사용하지 않도록 하는 방법 | hooni | 2003.04.23 | 13028 |