[英]Swift 3 (Xcode 8 beta 6) localizedStringWithFormat
Is there a better way to get a localized format and substitute strings in with Xcode 8 Swift 3? 是否有更好的方法来获取本地化格式并使用Xcode 8 Swift 3替换字符串? Do I need to use NSString, and cast back and forth between NSString and String? 我是否需要使用NSString,并在NSString和String之间来回转换?
let localizedDue = NSString.localizedStringWithFormat(NSLocalizedString("Due: %@", comment: "due date label with date") as NSString, formattedDate) as String
I may be missing something, but in Swift 3, String
has a type method localizedStringWithFormat
and you can write something like this: 我可能会遗漏一些东西,但在Swift 3中, String
有一个类型方法localizedStringWithFormat
,你可以写这样的东西:
let localizedDue = String.localizedStringWithFormat(NSLocalizedString("Due: %@", comment: "due date label with date"), formattedDate)
If this is not what you are seeking for, please update your post. 如果这不是您所寻求的,请更新您的帖子。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.