I have an assignment where I should create a product list in view controller with table view and custom cells. I customized the cell and I'm getting a error while compiling.
class ElectronicsTableViewCell: UITableViewCell {
@IBOutlet weak var productNameLabel: UILabel!
@IBOutlet weak var buyLabel: UILabel!
@IBOutlet weak var primeLabel: UILabel!
@IBOutlet weak var priceLabel: UILabel!
}
class ProductListViewController: UIViewController , UITableViewDelegate, UITableViewDataSource{
@IBOutlet weak var tableView:UITableView!
var electronicProducts = ["Swift DVD","Swift Manual","Beats EarPhones","IPad","I Watch"]
var price = ["45","34","67","90","89"]
override func viewDidLoad() {
super.viewDidLoad()
tableView.delegate=self
tableView.dataSource=self
tableView.register(UITableViewCell.self, forCellReuseIdentifier: "LabelCell")
// Do any additional setup after loading the view.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return electronicProducts.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell
{
let cell = tableView.dequeueReusableCell(withIdentifier: "LabelCell",for: indexPath as IndexPath) as! ElectronicsTableViewCell
let productName = electronicProducts [indexPath.row]
cell.productNameLabel?.text = productName
cell.buyLabel?.text = "Buy"
cell.primeLabel?.text = "Prime Eligible"
let productPrice = price [indexPath.row]
cell.priceLabel?.text = productPrice
return cell
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
print("you selected cell \(indexPath.row)")
}
}
The error is : Reading from private effective user settings. Could not cast value of type 'UITableViewCell' (0x10300f858) to 'assignment2.ElectronicsTableViewCell' (0x1013b3178). (lldb)