My Realm property isn't updating whenever I run my app

Hey guys so I developed an NoteApp, the wanted behavior is that whenever a user taps on one of the cells a checkmark appears and if tapped again the checkmark disappears . Here is what my code looks like.


class Item: Object {
@objc dynamic var title: String?
@objc dynamic var done: Bool = false


var toDoItems: Results<Item>!

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath)
    cell.textLabel?.text = toDoItems[indexPath.row].title
    cell.accessoryType = toDoItems[indexPath.row].done ? .checkmark : .none
    return cell   

func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
    try! realm.write {
        toDoItems![indexPath.row].done = !toDoItems![indexPath.row].done
    tableView.deselectRow(at: indexPath, animated: true)

So the problem is that whenever I tap on a cell the checkmark does not appear and my realm done property remains unchanged in Realm Studio . Please help!!

Cross post to Stackoverflow. It’s a good idea to keep questions in one place so we aren’t doing double duty in trying to answer.

My Realm property isn’t updating whenever I run my app

@Stephano_Luis_Felipe The old legacy realm demo app leveraged the checkmark in a tableView - you can see the code here -

Perhaps this can help you