Swift 3(Xcode 8 beta 6)localizedStringWithFormat
问题描述:
有没有更好的方法来获得本地化的格式,并用Xcode 8替换字符串Swift 3?我是否需要使用NSString,并在NSString和String之间来回转换?Swift 3(Xcode 8 beta 6)localizedStringWithFormat
let localizedDue = NSString.localizedStringWithFormat(NSLocalizedString("Due: %@", comment: "due date label with date") as NSString, formattedDate) as String
答
我可能失去了一些东西,但是在斯威夫特3,String
有一个类型的方法localizedStringWithFormat
,你可以写这样的事情:
let localizedDue = String.localizedStringWithFormat(NSLocalizedString("Due: %@", comment: "due date label with date"), formattedDate)
如果这是你正在寻找没有什么,请更新你的帖子。
谢谢。我以为我曾尝试过。也许Xcode中的代码完整工具没有帮助。 –