It's normal, it is out of scope :
If you format the code properly:
struct viewdetail: View {
@State var text1:String = ""
@State var tip1:String = ""
@State var text23:String = ""
@State var tip23:String = ""
var body: some View {
Text(text1);Text(tip1);Text(text23);Text(tip23)
}
}
func detailline(costa:inout [Double],tipa:inout [Double]) {
print(costa,tipa)
text1 = "125" // Cannot find 'text1' in scope
print("detail")
}
func îs defined OUT of viewDetail.
Hence, text1 in detailing is not defined.
You have to change as follows:
struct ViewDetail: View {
@State var text1:String = ""
@State var tip1:String = ""
@State var text23:String = ""
@State var tip23:String = ""
func detailLine(costa:inout [Double],tipa:inout [Double]) {
print(costa,tipa)
text1 = "125" // Now, Can find 'text1' in scope
print("detail")
}
var body: some View {
Text(text1);Text(tip1);Text(text23);Text(tip23)
}
}
Note also I changed the caps on names to follow Swift rules.
PS: when you ask a question:
format code with code formatter tool
take time to formulate the question in the text, not only the title.
Don't forget to close the thread once you've got the correct answer, by marking the answer as correct.