UITableViewDiffableDataSource
类,我将UITableViewDiffableDataSource
用于表视图的数据源。每当我尝试从数据源类内部获取ViewController的数据数组(或任何变量/函数)时,都会出现此错误:Instance member 'animalsArray' of type 'AnimalsVC' cannot be used on an instance of nested type 'AnimalsVC.DataSource'
我不确定为什么会收到此错误,因为我的DataSource类在ViewController类内。这是我的代码:
class AnimalsVC: UIViewController {
var animalsArray = []
class DataSource: UITableViewDiffableDataSource<Int, Animal> {
override func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool {
let items = animalsArray //<- This is where the error occurs
return true
}
}
}
我正在通过在ViewController(AnimalsVC)内创建UITableViewDiffableDataSource类来将UITableViewDiffableDataSource用于表视图的数据源。每当我尝试获取ViewController'...
我不确定为什么会收到此错误,因为我的DataSource类在ViewController类内。