Hi,
this is my first post here. I am doing the “Beginning Table Views” course on ios12 and implementing a TableViewController.
Problem: I’m tagging a View inside my TableView controller in UIBuilder and then access it by tag in the controller code. This strangely this works in all but one case. The contents of row 0 row of the TableView do not downcast to UILabel. I end up with one row in my output that carries the std. “Label”
Consider this controller for Exercise 7:
` override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) → UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: “ChecklistItem”, for: indexPath)
// tableView.viewWithTag accesses the inner with with a tag
print(indexPath.row)
if let label = tableView.viewWithTag(1000) as? UILabel {
switch indexPath.row % 5 {
case 0:
label.text = “Take a Jog”
case 1:
label.text = “Watch a movie”
case 2:
label.text = “Code an app”
case 3:
label.text = “Walk the dog”
case 4:
label.text = “Study Design”
default:
label.text = “unassigned”
}
}
return cell
}`
why would
‘if let label = tableView.viewWithTag(1000) as? UILabel’
hold true for all but the first row out of ten?