UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

SOLVED: The compiler is unable to type-check this expression in reasonable time; try breaking up the expression into distinct sub-expressions

Forums > SwiftUI

Hello i have problem with code but i dont know where is a error. When i add HStack into if-statement error appear, I want compare 2 keys in arrays

my code:


let decoding_ = try! JSONDecoder().decode([String:[Food]].self, from: decoding_url)

struct OrderMenu: View {
     @Binding var an_order_list : [String]

     //@State private var FoodDescription: String
     var body: some View {
         VStack{
             List {
                 ForEach(decoding_.keys, id: \.self){ i in
                     ForEach(decoding_[i]!){ k in
                         ForEach(an_order_list, id: \.self) { a in
                             if a == k.food_menu_id {
                                 HStack {
                                     Text(k.name)
                                     Text(k.alergens)
                                 }
                                 HStack {
                                     Text(k.description)

                                 }
                            }
                        }
                     }
                 }
             }
         }
     }
 }

  struct OrderMenu_Previews: PreviewProvider {

     static var previews: some View {
         OrderMenu(an_order_list: .constant(["Košík je prázdny"]))
     }
 }

1      

(FIXIT)If anyone will face it same problem as me. Just split your views into Small bits via @ViewBuilder

1      

Hacking with Swift is sponsored by RevenueCat.

SPONSORED Take the pain out of configuring and testing your paywalls. RevenueCat's Paywalls allow you to remotely configure your entire paywall view without any code changes or app updates.

Learn more here

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.