I am trying to populate my tableView with data from within an array, However when I try to assign the text of the Cell to the items in the array I keep getting the error:
Cannot assign value of type 'String.Type' to type 'String?
Here's my code as it stands, I've tried a few other ways but this one seems like it's the closest one.
class ContactViewController: UIViewController, UITableViewDataSource {
var contact:[Contacts]=[]
struct Contacts {
let name = String.self;
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "CustomCell", for: indexPath)
let contacts = contact[indexPath.row]
cell.textLabel?.text = contacts.name //This is where I get the error
return cell
}
}
Contactand the variablecontacts.var contact:[Contacts]=[]andlet contacts = contact[indexPath.row]is pretty confusing.