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      

BUILD THE ULTIMATE PORTFOLIO APP Most Swift tutorials help you solve one specific problem, but in my Ultimate Portfolio App series I show you how to get all the best practices into a single app: architecture, testing, performance, accessibility, localization, project organization, and so much more, all while building a SwiftUI app that works on iOS, macOS and watchOS.

Get it on Hacking with Swift+

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.