相关疑难解决方法(0)

如何使用XCode 6.3 Beta2从Swift中的SuperClass覆盖setter?

我的SuerClass UICollectionViewCell有一个属性:

var selected: Bool
Run Code Online (Sandbox Code Playgroud)

我的班级是

MyClass : UICollectionViewCell {

  func setSelected(selected: Bool) { 
    super.selected = selected
    // do something
 }

}
Run Code Online (Sandbox Code Playgroud)

前者在XCode 6.2中运行良好,但在XCode 6.3Beta2中它引发了一个错误:

Method 'setSelected' with Objective-C selector 'setSelected:' conflicts with setter for 'selected' from superclass 'UICollectionViewCell' with the same Objective-C selector
Run Code Online (Sandbox Code Playgroud)

如何解决这个问题与XCode 6.3 beta2一起使用?

编辑:我也试过了

  override func setSelected(selected: Bool) { 
    super.selected = selected
    // do something
 }
Run Code Online (Sandbox Code Playgroud)

这导致错误:

var selected: Bool
Run Code Online (Sandbox Code Playgroud)

inheritance overriding ios uicollectionviewcell swift

16
推荐指数
1
解决办法
1万
查看次数