Had this error for days now and I can't fix it

  1. struct ModelsByCategoryGrid: View {

2. @Binding var showBrowse: Bool

3. let models = Models()    

4. var body: some View {

5.    VStack { ForEach(ModelCategory.allCases, id: \.self) { category in                   

  1. //Only display the grid if the category contains items

7.  if let modelsByCategory = models.get(category: category) {  

8. HorizontalGrid(showbrowse: $showBrowse, title: category.label, items: modelsByCategory)         }

I GET AN ERROR FOR LINE 5 SAYING "MISSING ARGUMENT FOR PARAMETER IN #1 CALL"

Could you show the complete code ?

The following works without issue.

struct ContentView: View {
    enum ModelCategory: String, CaseIterable, Identifiable {
        case one, two, three, four, five, six

        var id: String {
            self.rawValue
        }
    }

    var body: some View {
        VStack {
            ForEach(ModelCategory.allCases, id: \.self) { value in
                Text(value.id)
            }
        }
    }
}

But because you have introduced a member variable that is not initialized this is the error being raised. If you have a preview snippet, pass the showBrowse param into the ModelsByCategoryGrid(showBrowse: Binding.constant(false)) or give the showBrowse a default value.

    @Binding var showBrowse: Bool
Had this error for days now and I can't fix it
 
 
Q