Edit existing items

I’m working in the edit items chapter and i’ve been struggling with this code how the method firstIndex(of:) can find the item that i passed back didn’t i change it’s text? what is it comparing to exactly? it should be like a new item and this method should return nil?

    func addItemViewController(_ controller: AddItemViewController, didFinishEditing item: ChecklistItem) {
        if let index = items.firstIndex(of: item) {
            let indexPath = IndexPath(row: index, section: 0)
            if let cell = tableView.cellForRow(at: indexPath) {
                configureText(for: cell, with: item)
        navigationController?.popViewController(animated: true)
1 Like

I don’t know much about it. But I would like to learn. Thank you so much!

This topic was automatically closed after 166 days. New replies are no longer allowed.