简体   繁体   中英

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? Do I need to use NSString, and cast back and forth between NSString and 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:

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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