Ios 带选择器错误的快速覆盖方法
我最近一直在学习swift,在打开以前测试版的项目时,我在尝试编译时遇到了这个错误Ios 带选择器错误的快速覆盖方法,ios,xcode,uitableview,swift,Ios,Xcode,Uitableview,Swift,我最近一直在学习swift,在打开以前测试版的项目时,我在尝试编译时遇到了这个错误 Overriding method with selector 'initWithStyle:reuseIdentifier:' has incompatibe type '(UITableViewCellStyle, String) -> SweetTableViewCell' 这是给出错误的代码行 override init(style: UITableViewCellStyle, reuseIden
Overriding method with selector 'initWithStyle:reuseIdentifier:' has incompatibe type '(UITableViewCellStyle, String) -> SweetTableViewCell'
这是给出错误的代码行
override init(style: UITableViewCellStyle, reuseIdentifier: String) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
// Initialization code
}
苹果在新的XCode版本中提供了许多可选参数和方法值。在您的例子中,第二个参数--
reuseIdentifier
-应该是String?
而不是String
,这是因为UITableViewCell
中的init
方法发生了一些变化:
init(style: UITableViewCellStyle, reuseIdentifier: String?)
^
reuseIdentifier
现在是可选字符串