поэтому сначала я создал пользовательский объект:
import Foundation
class Website {
var name:String
var pictureLabel:String
init(title:String,pictureLabel:String) {
name = title
pictureLabel = picture
}
}
, а затем в моем классе tableviewcontroller:
class ViewController:
UIViewController,UITableViewDelegate,UITableViewDataSource {
var websites = [Website]()
@IBOutlet weak var tableView: UITableView!
override func viewDidLoad() {
super.viewDidLoad()
tableView.delegate = self
tableView.dataSource = self
tableView.rowHeight = 80
tableView.register(MyCell.self, forCellReuseIdentifier: "MyCell")
websites.append(Website(title: "facebook.com", pictureLabel: "facelogo"))
print(websites)
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return websites.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "MyCell", for: indexPath) as! MyCell
cell.label.text = websites[indexPath.row].name
return cell }
ошибка: фатальная ошибка: неожиданно обнаружен ноль при неявном развертывании Необязательное значение: file