Swift3 enum的Swift 3.0本地化包
使用swift 3.0,我尝试创建枚举,其中不同的值及其描述将根据枚举类型获得,这取决于本地化语言。但下面的代码未编译,因为包参数无效,因为此处self在枚举中不是有效类。关于如何解决本地化问题,有什么建议吗Swift3 enum的Swift 3.0本地化包,swift3,Swift3,使用swift 3.0,我尝试创建枚举,其中不同的值及其描述将根据枚举类型获得,这取决于本地化语言。但下面的代码未编译,因为包参数无效,因为此处self在枚举中不是有效类。关于如何解决本地化问题,有什么建议吗 public enum TempEnumValues : Int { case first case second case third var values: Int { switch self {
public enum TempEnumValues : Int
{
case first
case second
case third
var values: Int
{
switch self
{
case .first:
return 1
case .second:
return 2
case .third:
return 3
}
}
var description: String
{
let bundle = Bundle(for: CLASS_NAME.self))
switch self
{
case .first:
return NSLocalizedString("First Value", bundle: bundle, comment: "")
case .second:
return NSLocalizedString("Second Value", bundle: bundle, comment: "")
case .third:
return NSLocalizedString("Third Value", bundle: bundle, comment: "")
}
}
}
我找到了答案&更新的代码