我想生成一个所有区域设置标识符的列表,供用户选择作为默认值。类似于在标准设置中选择区域。
因此,我想生成一个列表,其中包含例如“澳大利亚”、“奥地利”、“阿塞拜疆”、...、“也门”、“赞比亚”、“津巴布韦”。如果用户选择“澳大利亚”,我想返回en_AU.
所以需要确定下Locale可以使用的属性以及如何遍历它。
目前,只是想看看我是否可以返回文本,例如“澳大利亚”:
Text(Locale.localizedString(Locale.init(identifier: Locale.availableIdentifiers[0].description)))
Run Code Online (Sandbox Code Playgroud)
但是返回错误:
Closure containing control flow statement cannot be used with function builder 'ViewBuilder'
Run Code Online (Sandbox Code Playgroud)
谢谢