How to get language locale of the user in Objective-C?

后端 未结 6 1311
野性不改
野性不改 2021-02-06 05:41

I am developing an application for Mac OS X. I want to change indication contents by the language locale (English, Spanish, etc.) of the application user, how do I get informati

6条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-02-06 06:22

    To be exact there is a change with iOS 9 and greater where [NSLocale preferredLanguages] now return - instead of only . So it's better to do:

    NSString *languageOS = [[NSLocale preferredLanguages] objectAtIndex:0];
    
    if([[[UIDevice currentDevice] systemVersion] floatValue] >= 9.0) {
        languageOS = [[languageOS componentsSeparatedByString:@"-"] objectAtIndex:0];
    }
    

提交回复
热议问题