TEAM LICENSES: Save money and learn new skills through a Hacking with Swift+ team license >>

Edit Core Data list items in place (extending Hacking with macOS Bookworm project)

Forums > macOS



Could anyone point me in the right direction in order to edit Core Data list items "in place" similar to how you can rename your files and folders in the Xcode files list by clicking on it after selecting it and then the list item changes into an editable text field?

For example, in the Hacking with macOS Bookworm project, we create a sidebar with a list of book names and selecting the item in the list changes the detail view to reflect that book. And while we can edit the name in the detail view and it will be reflected in the list view, I am curious to know how in place editing can be achieved.

Thank you!


What kind of view are you using for the list items?

If you use a TextField for the list item, you should be able to change the name of the book from the sidebar.



Well, the current non-editable list looks like:

        List(reviews) { review in
            NavigationLink(tag: review, selection: $selectedReview) {
                DetailView(review: review)
            } label: {


  1. I can't seem to create a binding to the review in the list in order to use a TextField like I was using this syntax in the following test code:
        List($dataSource.items) {$item in
            TextField(, text: $

I imagine it is because "reviews" is defined as follows:

    @FetchRequest(sortDescriptors: [SortDescriptor(\.id)]) var reviews: FetchedResults<Review>


  1. The example in #1 above showed me that the items in the list can no longer be selected, but just edited when you click on them. This makes me think you need to somehow change the item in the list from a Text to a TextField when you click on a selected item or something. seems like it should be straightforward since it is done in so many applications, but maybe it isn't!


Apple has changed the standard behavior in a recent macOS update. I have the following project on GitHub:


The Mac version used to work properly. Now it shows the same behavior you're experiencing: clicking on a list item lets you change its title but won't let you select the item. Now you have to either use the up and down arrow keys or double-click the item to select it, which seems like odd default behavior to me. It makes more sense to have single-click select the item and double-click edit the item.



Thanks for trying to point me in the right direction! I can see from your demo that at least you can click outside the text area to select a row...I was too quick and didn't implement the selected row feature in my test, so that's better than nothing.

However, I can't get it to work at all on top of a core data fetched request result set, so I'll have to keep looking.

Thanks again!


Hacking with Swift is sponsored by Superwall.

SPONSORED Superwall lets you build & test paywalls without shipping updates. Run experiments, offer sales, segment users, update locked features and more at the click of button. Best part? It's FREE for up to 250 conversions / mo and the Superwall team builds out 100% custom paywalls – free of charge.

Learn More

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

Unknown user

You are not logged in

Log in or create account

Link copied to your pasteboard.