我查看了Shape和Line。它们都有cellForRowAt:..
,但class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {
let arrayOne = [One(cellID: "1", name: "hello", lastName: "hello last", cellID2: "1"), One(cellID: "1", name: "hello", lastName: "hello last", cellID2: "1"), One(cellID: "1", name: "hello", lastName: "hello last", cellID2: "2"), One(cellID: "1", name: "hello", lastName: "hello last", cellID2: "1"), One(cellID: "1", name: "hello", lastName: "hello last", cellID2: "2"), One(cellID: "1", name: "hello", lastName: "hello last", cellID2: "1")]
var filteredArray = [One]()
@IBOutlet weak var compareTableView: UITableView!
override func viewDidLoad() {
super.viewDidLoad()
// Here you apply your filter
filteredArray = arrayOne.filter { $0.cellID == $0.cellID2 }
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return filteredArray.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "CompareTableViewCell") as! CompareTableViewCell
let arrayID = filteredArray[indexPath.row]
// Feed your cell
return cell
}
}
在构造函数中有scensFunc
个参数。
Shape
和drawFunc
之间有区别吗?为什么drawFunc
在构造函数中有一个绘制函数对象?
答案 0 :(得分:0)
drawFunc
并将其重命名为sceneFunc
。所以只需使用sceneFunc
。