Quick override method with selector error

I recently studied fast and, opening a project from a previous beta, I get this error when trying to compile

Overriding method with selector 'initWithStyle:reuseIdentifier:' has incompatibe type '(UITableViewCellStyle, String) -> SweetTableViewCell'

And here is the line of code giving the error

override init(style: UITableViewCellStyle, reuseIdentifier: String) {
    super.init(style: style, reuseIdentifier: reuseIdentifier)
    // Initialization code
}
+4
source share
2 answers

This is because the method initin has UITableViewCellbeen changed a bit:

init(style: UITableViewCellStyle, reuseIdentifier: String?)
                                                         ^

reuseIdentifier is now an optional string.

+3
source

Apple makes many arguments and method values ​​optional in newer versions of Xcode. In your case, the second argument - reuseIdentifier- should be String?not String.

+1
source

All Articles