App not Updated for Newer Version of Swift | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

App not Updated for Newer Version of Swift

I have realized, as I've gone through the swift lessons, that I am using a newer version of Swift than the lessons use. I would really like to finish the app, but now I'm stuck at lesson 12/18, slide 4/4 where it says: override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { let cellIdentifier = "ItemTableViewCell" let cell = tableView.dequeueReusableCellWithIdentifier( cellIdentifier, forIndexPath:indexPath) as! ItemTableViewCell let item = items[indexPath.row] cell.nameLabel.text = item.name return cell } In my version the code says this: override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let cellIdentifier = "ItemTableViewCell" let cell = tableView.dequeueReusableCell(withIdentifier: cellIdentifier, for: indexPath) let item = items[indexPath.row] cell.textLabel.text = item.name return cell } There is no member nameLabel so I changed mine to textLabel, but that is giving me an error. Has someone figured this out?

27th Oct 2016, 12:40 AM
Zeke Williams
Zeke Williams - avatar
1 Answer
0
The problem of in your code is you didn't specify type of cell so your code using default 'UITableViewCell()' instead of your custom created cell 'ItemTableViewCell' . Little thing I didn't saw the slides but I think if you did every thing right in your code this might work as well. override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let cellIdentifier = "ItemTableViewCell" let cell = tableView.dequeueReusableCell(withIdentifier: cellIdentifier, for: indexPath) as! ItemTableViewCell let item = items[indexPath.row] cell.nameLabel.text = item.name return cell } hope this will help
3rd Nov 2016, 10:58 PM
asa