Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

6.0.1 and Table changes "UILabel? does not have a member named 'text"

Tags:

ios

swift

xcode6

I'm working my way through the Swift table demos, and all of them seem have this same error message under 6.0.1. Not sure how to tackle this:

enter image description here

like image 785
Edward Potter Avatar asked Sep 21 '14 23:09

Edward Potter


2 Answers

try this:

cell.textLabel!.text = self.tableData[indexPath.row]

And read this article about optionals here: Optionals in Swift

Update:

A better approach is now to use:

cell.textLabel?.text = self.tableData[indexPath.row]
like image 146
derdida Avatar answered Nov 15 '22 23:11

derdida


In Xcode 6.1.1 you have to unwrap both the cell and textLabel:

cell!.textLabel!.text = "your text"

like image 42
BA_ Avatar answered Nov 15 '22 23:11

BA_