2

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
Jason Hocker
  • 6,585
  • 9
  • 39
  • 76

1 Answers1

8

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.

OOPer
  • 44,179
  • 5
  • 90
  • 123