I 현재 가지고 그 INIT 함수 지정 데이터 소스를 설정하는있는 UITableViewController :있는 UITableViewController
가class BookmarkTableViewController: UITableViewController {
var date: Date
// MARK: - Init
init(date: Date, fetchAtLoad: Bool) {
self.date = date
super.init(style: .plain)
self.tableView.dataSource = BookmarkDataSource(date: date)
self.tableView.register(UITableViewCell.self, forCellReuseIdentifier: "cell")
}
// ...
}
맞춤 데이터 소스는 다음과 같다 :
class BookmarkDataSource: NSObject {
let date: Date
init(date: Date) {
self.date = date
super.init()
}
}
// MARK: - UITableViewDataSource
extension BookmarkDataSource: UITableViewDataSource {
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 3
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = UITableViewCell()
cell.textLabel?.text = "Test content"
return cell
}
}
그러나 시뮬레이터 또는 장치에서 실행할 때 테이블보기에 아무 것도 나타나지 않습니다. 아무도 내가 빠진 것을 아는가?
참고 : 나는 당신의 세포가 제대로 인스턴스화되지 않는 생각 엑스 코드 8.0 베타와 스위프트 3.
예! 이거 야. 감사! – Aliou
나는 dataSource 변수 생성에 실패했지만 아이디어를 얻었습니다! – bradkratky