简体   繁体   English

regionCode 将在 iOS 16 中弃用

[英]regionCode will be deprecated in iOS 16

From iOS 16, regionCode depricated when try to access regionCode from current locale.从 iOS 16 开始,当尝试从当前语言环境访问regionCode时, regionCode被弃用。 Like this code喜欢这段代码

let locale = Locale.current
locale.regionCode

在此处输入图像描述

Solution for iOS 16 and earlier version iOS 16及更早版本解决方案

    let locale = Locale.current
    var countryCode = ""
    if #available(iOS 16, *) {
        if let value = locale.region?.identifier {
            countryCode = value
        }
    } else {
        if let value = locale.regionCode {
            countryCode = value
        }
    }
    print(countryCode)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM