I am new to Swift. I have a simple class in swift
class ListItem: NSObject {
let itemName: String
var completed: Bool
init(itemName: String, completed: Bool = false)
{
self.itemName = itemName
self.completed = completed
}
}
When I refer to this class in my TableViewController, I get the following error: "Instance member itemName cannot be used on type ListItem".
My TableViewController code (cellForRowAtIndexPath method) is shown below.
let tempCell = tableView.dequeueReusableCellWithIdentifier("triggerCell")! as UITableViewCell
let listItem = listItems[indexPath.row]
// Downcast from UILabel? to UILabel
let cell = tempCell.textLabel as UILabel!
cell.text = ListItem.itemName
if (ListItem.completed)
{
tempCell.accessoryType = UITableViewCellAccessoryType.Checkmark;
}
else
{
tempCell.accessoryType = UITableViewCellAccessoryType.None;
}
return tempCell
}
I'm probably making a basic error, but I can't seem to identify where I'm going wrong.