Hi,
In a UITableViewCell class I want to find a UILabel subview using a tag, but am struggling to understand the safest/cleanest way to do it. This has the correct result, but doesn't feel it's the best way.
guard let returnedView = tableCell.contentView.viewWithTag(99) else {
return cell
}
let labelView = returnedView as! UILabel
labelView.text = "my text"
Alternatively I can do this, but is this 'safe'? What happens if viewWithTag returns nil, is the forced downcast ignored? I assume the downcast is only acted upon if viewWithTag returns something to downcast (and is true in the wider sense). But in that case, would the labelView (line 02) setting of text just be ignored also?
let labelView = (tableCell.contentView.viewWithTag(99)) as! UILabel
labelView.text = "my text"
thanks,