Sru*_*mha 6 inheritance uitableview ios ios-frameworks swift
我open
BaseViewController
在核心框架中有一个类,它实现了 tableview 数据源方法。假设我有另一个类(在模块之外)ClassA
,BaseViewController
因为它是超类。当我尝试覆盖 tableview 数据源方法时,它抛出了这个错误Overriding non-open instance method outside of its defining module
。
BaseViewController
看起来像这样
open class BaseViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {
...
public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 0
}
public func numberOfSections(in tableView: UITableView) -> Int {
return 0
}
public func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
return UITableViewCell()
}
}
Run Code Online (Sandbox Code Playgroud)
A类
import CustomCoreFramework
class ClassA : BaseViewController {
// throws an error
public override func numberOfSections(in tableView: UITableView) -> Int {
return tableViewListItems.count
}
}
Run Code Online (Sandbox Code Playgroud)
我想open
类方法应该可以在模块外部访问。我尝试将 tableview 方法访问说明符更改为public
不同的组合,但似乎没有任何效果。