In my code in Swift:
override func tableView(tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
let stringIdent = String(format: "section_1_%d", section)
return NSLocalizedString(stringIdent, comment: nil)
}
I am shown an error when running the build:
Type 'string' does not conform to protocol NilLiteralConvertible
This code always worked in Objective-C.
What could be wrong in Swift?
comment
is declared as String
and not String?
. You cannot use nil
there. Use ""
instead.
return NSLocalizedString(stringIdent, comment: "")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With