Development Note/iOS

[objective-c] 언어코드 가져오기

JamesChun 2020. 8. 13. 19:14
+ (NSString*) getLanguageCode
{
    NSString *language = [[NSLocale preferredLanguages] firstObject];
    NSDictionary *languageDic = [NSLocale componentsFromLocaleIdentifier:language];
    NSString *preferredLanguageCode = [languageDic objectForKey:@"kCFLocaleLanguageCodeKey"];

    return preferredLanguageCode;
}
//output : ko

출처
https://stackoverflow.com/questions/3910244/getting-current-device-language-in-ios