Cannot convert value of type '[ChecklistItem]' to expected argument type 'Range<Int>'

In Chapter 13 of IOS Apprentice after changing the code to use extensions to mitigate the IOS limitation that prevents passing a binding in the ForEach loop, I get the following error:

Cannot convert value of type ‘[ChecklistItem]’ to expected argument type ‘Range’.

Here is the code that throws the error:

var body: some View {
NavigationView {
List {
ForEach(checklist.items) { index in
RowView(checklistItem: self.$checklist.items[index])
}

I’m stumped as I have copied the code from the files provided with the ebook and the error still shows up. Also tried restarting XCODE etc… and have looked in the forums for similar problems as well as on the Apple dev forums without finding anything. Has anybody run across this before?

I figured out what I did wrong, when I copied the Extensions folder over I did not check the “Copy items if needed” checkbox or the “Create groups” option… basically did not follow the instructions properly.

My apologies for cluttering up the forum with my inattentiveness.

it’s not working for me

1 Like

Hi @jslnwsky, welcome to the forum community! Glad you were able to figure out the issue and thanks for providing us with an update! @saipurva, are you having the same issue?

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