1

I have checked all identifiers name and also checked the its class' name and all. Below is my code and error.

class StoreInfoViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {


var store : StoreInfo = StoreInfo()

@IBOutlet weak var storeInfoTable: UITableView!


override func viewDidLoad() {
    super.viewDidLoad()

    storeInfoTable.register(UINib(nibName: "CustomStoreInfoTableOneViewCell", bundle: nil), forCellWithReuseIdentifier: "storeinfocell1")

    storeInfoTable.delegate = self
    storeInfoTable.dataSource = self


}

func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    return 1
}

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    let cell = storeInfoTable.dequeueReusableCell(withIdentifier: "storeinfocell1", for: indexPath) as! CustomStoreInfoTableOneViewCell

    cell.storeInfoImage.sd_setImage(with: URL(string: (store.imageurl)), placeholderImage: UIImage(named: "r1"), options: [.continueInBackground, .progressiveDownload], completed: nil)

    cell.storeinfoName.text = store.storename

}

}

Here's the error.

Kazunori Takaishi
  • 2,268
  • 1
  • 15
  • 27
Parth Rudakia
  • 151
  • 16
  • Possible duplicate of [Custom UITableViewCell from nib in Swift](https://stackoverflow.com/questions/25541786/custom-uitableviewcell-from-nib-in-swift) – Trupesh Vaghasiya May 26 '18 at 11:15

2 Answers2

1

You write wrong syntax

  self. storeInfoTable.register(UINib(nibName: "CustomStoreInfoTableOneViewCell", bundle: nil), forCellReuseIdentifier: "storeinfocell1")
Abdelahad Darwish
  • 5,969
  • 1
  • 17
  • 35
0

You are registered your nib with ( :forCellWithReuseIdentifier) but your need to register your nib with ( : forCellReuseIdentifier). Please change your register line with this.

storeInfoTable.register(UINib(nibName: "CustomStoreInfoTableOneViewCell", bundle: nil), forCellReuseIdentifier: "storeinfocell1")
Jogendar Choudhary
  • 3,476
  • 1
  • 12
  • 26