Josh
Josh

Reputation: 43

swift overriding method with selector error

I've recently been learning swift and upon opening a project from a previous beta version I get this error when trying to compile

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

And here's the line of code giving the error

override init(style: UITableViewCellStyle, reuseIdentifier: String) {
    super.init(style: style, reuseIdentifier: reuseIdentifier)
    // Initialization code
}

Upvotes: 4

Views: 495

Answers (2)

Antonio
Antonio

Reputation: 72760

That's because the init method in UITableViewCell has been changed a little bit:

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

the reuseIdentifier is now an optional string.

Upvotes: 3

Wojtek Surowka
Wojtek Surowka

Reputation: 21003

Apple makes many arguments and method values optional in new XCode versions. In your case the second argument - reuseIdentifier - should be String? not String.

Upvotes: 1

Related Questions