# Edit existing items

**URL:** <https://forums.kodeco.com/t/edit-existing-items/165048>\
**Category:** iOS Apprentice\
**Created:** [February 19, 2022, 10:08pm UTC](https://forums.kodeco.com/t/edit-existing-items/165048 "2022-02-19T22:08:31Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ahmednagy](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/ahmednagy/32/102075_2.png) [@ahmednagy](https://forums.kodeco.com/u/ahmednagy)\
**Post date:** [February 19, 2022, 10:08pm UTC](https://forums.kodeco.com/t/edit-existing-items/165048/1 "2022-02-19T22:08:31Z")

</div>

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?

```auto
    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)
    }

```

---

<div class="post-metadata">

**Author:** ![frankiebriley](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/frankiebriley/32/102075_2.png) [@frankiebriley](https://forums.kodeco.com/u/frankiebriley)\
**Post date:** [February 21, 2022, 10:46am UTC](https://forums.kodeco.com/t/edit-existing-items/165048/2 "2022-02-21T10:46:52Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://s3.amazonaws.com/cdn.raywenderlich.com/community/forum-assets/noun-game-ghost-878668.png) [@system](https://forums.kodeco.com/u/system)\
**Post date:** [August 5, 2022, 2:09pm UTC](https://forums.kodeco.com/t/edit-existing-items/165048/3 "2022-08-05T14:09:07Z")

</div>

Closed on August 5, 2022, 2:09pm UTC

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