Code Block The compiler is unable to type-check this expression in reasonable time; try breaking up the expression into distinct sub-expressions
How do I stop this error?
my code is:
Code Block The compiler is unable to type-check this expression in reasonable time; try breaking up the expression into distinct sub-expressions
You should better include the core part of your code as Code block.my code can be found here: code
Thanks for moving your code into Text Attachment.I can't because there is a character limit
Code Block var bodyGroup: some View { Group { Text(launch.name) .font(.system(size: 23)) .frame(maxWidth: .infinity, alignment: .leading) .fixedSize(horizontal: false, vertical: true) Text(Date(timeIntervalSince1970: launch.date_unix).getFormattedDate(format: "dd/MM/yyyy HH:mm:ss")) .font(.system(size: 11.5)) .foregroundColor(Color.gray) .frame(maxWidth: .infinity, alignment: .leading) .fixedSize(horizontal: false, vertical: true) Spacer() } }
The same original error
Cannot find 'launch' in scope (line 5)
Cannot find 'launch' in scope (line 13)
Generally, when you get The compiler is unable to type-check this expression, there may be multiple type-related errors, that Swift compiler could not detect. So, while breaking up, you may find more and more errors.now I get more errors
You need to split up codes until the same error is not generated
The same original error
You use launch in your definition of bodyGroup, that should be declared inside the scope of bodyGroup.
Cannot find 'launch' in scope (line 5)
Cannot find 'launch' in scope (line 13)
Code Block func bodyGroup(_ launch: Launch) -> some View { //... }
Code Block bodyGroup(launch)
Big advance!it got rid of the original error
Having multiple things with the same name may not be good for programming, especially when the code being complex enough.now I get the error Cannot convert value of type '(inout [Rocket]) -> ()' to expected argument type '([Rocket]) -> ()' on line 45
Code Block rocketApiCall().getUsers{ (rockets) in self.rockets = rockets} //<- Please do not miss `self.`
Code Block import SwiftUI import SDWebImage import HalfModal import Foundation struct rocketView: View { @State var rockets: [Rocket] = [] @State private var showingHalfModal2: Bool = false var body: some View { ZStack { NavigationView { VStack { Spacer() .frame(height: 1) .navigationBarTitle("Rockets") List { ForEach(rockets, id: \.id) { rocket in Button(action: { withAnimation { self.showingHalfModal2 = true } }) { rHStack(rocket) } .buttonStyle(PlainButtonStyle()) } } }.onAppear { rocketApiCall().getUsers{ (rockets) in rockets = rockets} }.listStyle(SidebarListStyle()) .frame(alignment: .center) } } if showingHalfModal2 { HalfModalView(content: AnyView(HStack { VStack { Text("test123") .padding() } }), header: AnyView(HStack { VStack(alignment: .leading) { Text("test") Text("test") .font(.system(size: 10)) .foregroundColor(Color.gray) }}), isPresented: $showingHalfModal2) } } func rHStack(_ rocket: Rocket) -> some View { HStack { Group { Text(rocket.name) .font(.system(size: 23)) .frame(maxWidth: .infinity, alignment: .leading) .fixedSize(horizontal: false, vertical: true) Text("Active: " + String(rocket.active)) .font(.system(size: 15)) .foregroundColor(Color.gray) Spacer() } } } } struct rocketView_Previews: PreviewProvider { static var previews: some View { rocketView() } }
So the error is now line 34.I have moved quite a chunk of code to a new Swift file called rocketView, it got rid of the original error, but now I get the error Cannot convert value of type '(inout [Rocket]) -> ()' to expected argument type '([Rocket]) -> ()' on line 45... my code is attached. (Line 45 is the line between }.onAppear { and }.listStyle...
Happy to hear that.OOPer's method worked!
You should better start a new thread.it now doesn't display correctly...