I have an open
BaseViewController
class in core framework that has tableview datasource methods implemented. Let's say I've another class (outside the module) ClassA
with BaseViewController
as it's superclass. When I try to override tableview datasource methods, it's throwing this error Overriding non-open instance method outside of its defining module
.
我在核心框架中有一个开放的BaseViewController类,它实现了tableview数据源方法。假设我有另一个类(在模块外)ClassA和BaseViewController,因为它是超类。当我尝试覆盖tableview数据源方法时,它会抛出此错误覆盖其定义模块之外的非打开实例方法。
BaseViewController
looks like this
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()
}
}
ClassA
ClassA的
import CustomCoreFramework
class ClassA : BaseViewController {
// throws an error
public override func numberOfSections(in tableView: UITableView) -> Int {
return tableViewListItems.count
}
}
I suppose the open
class methods should be accessible outside the module. I tried changing the tableview methods access specifiers to public
and different combinations but nothing seems to work.
我想开放类方法应该可以在模块外部访问。我尝试将tableview方法访问说明符更改为公共和不同的组合,但似乎没有任何工作。
1 个解决方案
#1
2
The BaseViewController’s methods should be declared open. This is discuss in the thread in reference.
BaseViewController的方法应该声明为open。这是在参考线程中讨论的。
See What is the 'open' keyword in Swift?
请参阅Swift中的'open'关键字是什么?
#1
2
The BaseViewController’s methods should be declared open. This is discuss in the thread in reference.
BaseViewController的方法应该声明为open。这是在参考线程中讨论的。
See What is the 'open' keyword in Swift?
请参阅Swift中的'open'关键字是什么?