Plz guys i need help with this
so first i made a custom object
import Foundation
class Website {
var name:String
var pictureLabel:String
init(title:String,pictureLabel:String) {
name = title
pictureLabel = picture
}
}and then on my tableviewcontroller class :
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 }
error : Fatal error: Unexpectedly found nil while implicitly unwrapping an Optional value: file