Post

Replies

Boosts

Views

Activity

Reply to cannot find in scope
Thanks for answering. I'm sorry I'm not sure how to go about it. Is AnotherView a function? How do I call AnotherView? I have no experience with binding. I can't follow what you wrote. Can you rewrite what you wrote with more detail? Please help.
Dec ’24
Reply to cannot find in scope
Let me explain. The user(driver) enters the cost of the delivery and the amount he got paid. The program(enterp) figures out the tip, tip %, average tip, total costs, total tips, total tip % and total cash and writes it out to the screen. Using detailLine I want to print all deliveries(up to 44) and tips to the second screen. I hope this helps.
Dec ’24
Reply to cannot find text1 in scope
I call enterp from a button. The button is in var some body. I'll send the code. Look at the bottom. var body: some View { NavigationStack { VStack { Text(" " + Date().formatted(date: .numeric, time: .omitted)) .foregroundColor(.black) .fontWeight(.bold) Text("Driver's Food Delivery") .font(.largeTitle) .fontWeight(.bold) Image("Screenshot 2024") HStack { Text("Cost") .font(.largeTitle) .padding(10) Spacer() Text("Paid") .font(.largeTitle) .padding(10) Spacer() Text("Tip") .font(.title) Spacer() Text("Tip %") .font(.title) } HStack { TextField("Cost", text: $cost) .frame(width: 75, height: 25) .padding(20) .fontWeight(.bold) .font(.system(size: 22)) .foregroundColor(.blue) .background(Color.brown) .cornerRadius(025) TextField("Paid", text: $paid) .frame(width: 75, height: 25) .padding(20) .fontWeight(.bold) .font(.system(size: 22)) .foregroundColor(.blue) .background(Color.brown) .cornerRadius(025) Text(tipp) .frame(width: 95, height: 25) .background(Color.white) .fontWeight(.bold) .font(.system(size: 22)) .foregroundColor(.blue) Text(tipc) .frame(width: 75, height: 5) .padding(10) .background(Color.white) .fontWeight(.bold) .font(.system(size: 22)) .foregroundColor(.blue) } VStack { Text (emsg) .foregroundColor(.red) Text (msg) .foregroundColor(.blue) HStack { Text (msg2) .foregroundColor(.blue) Spacer() } Button { enterp() } label: { Text("Enter") .font(.largeTitle) .foregroundColor(.green ) }
Dec ’24
Reply to cannot find in scope
Yes I call enterp() from a button. But it's not in viewdetail. It's in the main program(var some body). var body: some View { NavigationStack { VStack { Text(" " + Date().formatted(date: .numeric, time: .omitted)) .foregroundColor(.black) .fontWeight(.bold) Text("Driver's Food Delivery") .font(.largeTitle) .fontWeight(.bold) Image("Screenshot 2024") HStack { Text("Cost") .font(.largeTitle) .padding(10) Spacer() Text("Paid") .font(.largeTitle) .padding(10) Spacer() Text("Tip") .font(.title) Spacer() Text("Tip %") .font(.title) } HStack { TextField("Cost", text: $cost) .frame(width: 75, height: 25) .padding(20) .fontWeight(.bold) .font(.system(size: 22)) .foregroundColor(.blue) .background(Color.brown) .cornerRadius(025) TextField("Paid", text: $paid) .frame(width: 75, height: 25) .padding(20) .fontWeight(.bold) .font(.system(size: 22)) .foregroundColor(.blue) .background(Color.brown) .cornerRadius(025) Text(tipp) .frame(width: 95, height: 25) .background(Color.white) .fontWeight(.bold) .font(.system(size: 22)) .foregroundColor(.blue) Text(tipc) .frame(width: 75, height: 5) .padding(10) .background(Color.white) .fontWeight(.bold) .font(.system(size: 22)) .foregroundColor(.blue) } VStack { Text (emsg) .foregroundColor(.red) Text (msg) .foregroundColor(.blue) HStack { Text (msg2) .foregroundColor(.blue) Spacer() } Button { enterp() } label: { Text("Enter") .font(.largeTitle) .foregroundColor(.green ) } I'm going to have text1 to text44. What else do you need to know?
Dec ’24
Reply to cannot find in scope
func enterp() { var ipc = 50.0 var ipcc = 50.0 var tippp = 0.0 var totalcsh = 0.0 var ttips = 0.0 var tcost = 0.0 var tipo = 0.00 costt = Double(cost) paidt = Double(paid) emsg = "" if (costt != nil) && (paidt != nil) { tipo = (Double(paid)! - Double(cost)!) tipa.append (tipo) costa.append (Double(cost)!) number += 1 numbc = String(number) ttips = (tipa.reduce(0, +)) tcost = (costa.reduce(0,+)) tippp = (ttips / Double(number)) tipaa = tippp.formatted(.currency(code: "USD")) totaltips = ttips.formatted(.currency(code: "USD")) totalcost = tcost.formatted(.currency(code: "USD")) tipp = tipo.formatted(.currency(code: "USD")) tipc = String(tipo / Double(cost)! * 100) ipc = Double (tipc)! tipc = String(format: "%3.0f%%", ipc) tipcc = String(ttips / tcost * 100) ipcc = Double (tipcc)! tipcc = String(format: "%3.0f%%", ipcc) totalcsh = (tcost + ttips) totalcash = totalcsh.formatted(.currency(code: "USD")) } else { emsg = "Enter numbers and 1 decimal point only." } detailLine(costa: &costa,tipa: &tipa) } }
Dec ’24
Reply to cannot find in scope
Thanks for answering. I'm sorry I'm not sure how to go about it. Is AnotherView a function? How do I call AnotherView? I have no experience with binding. I can't follow what you wrote. Can you rewrite what you wrote with more detail? Please help.
Replies
Boosts
Views
Activity
Dec ’24
Reply to cannot find in scope
Let me explain. The user(driver) enters the cost of the delivery and the amount he got paid. The program(enterp) figures out the tip, tip %, average tip, total costs, total tips, total tip % and total cash and writes it out to the screen. Using detailLine I want to print all deliveries(up to 44) and tips to the second screen. I hope this helps.
Replies
Boosts
Views
Activity
Dec ’24
Reply to cannot find in scope
Can I do this if I'm gonna have 44 Texts(text1 thru text44)? I'll have 44 arguments to pass in. Enterp is in some view. How do I call it?
Replies
Boosts
Views
Activity
Dec ’24
Reply to cannot find in scope
You didn't answer https://developer.apple.com/forums/thread/771150.
Replies
Boosts
Views
Activity
Dec ’24
Reply to cannot find text1 in scope
I call enterp from a button. The button is in var some body. I'll send the code. Look at the bottom. var body: some View { NavigationStack { VStack { Text(" " + Date().formatted(date: .numeric, time: .omitted)) .foregroundColor(.black) .fontWeight(.bold) Text("Driver's Food Delivery") .font(.largeTitle) .fontWeight(.bold) Image("Screenshot 2024") HStack { Text("Cost") .font(.largeTitle) .padding(10) Spacer() Text("Paid") .font(.largeTitle) .padding(10) Spacer() Text("Tip") .font(.title) Spacer() Text("Tip %") .font(.title) } HStack { TextField("Cost", text: $cost) .frame(width: 75, height: 25) .padding(20) .fontWeight(.bold) .font(.system(size: 22)) .foregroundColor(.blue) .background(Color.brown) .cornerRadius(025) TextField("Paid", text: $paid) .frame(width: 75, height: 25) .padding(20) .fontWeight(.bold) .font(.system(size: 22)) .foregroundColor(.blue) .background(Color.brown) .cornerRadius(025) Text(tipp) .frame(width: 95, height: 25) .background(Color.white) .fontWeight(.bold) .font(.system(size: 22)) .foregroundColor(.blue) Text(tipc) .frame(width: 75, height: 5) .padding(10) .background(Color.white) .fontWeight(.bold) .font(.system(size: 22)) .foregroundColor(.blue) } VStack { Text (emsg) .foregroundColor(.red) Text (msg) .foregroundColor(.blue) HStack { Text (msg2) .foregroundColor(.blue) Spacer() } Button { enterp() } label: { Text("Enter") .font(.largeTitle) .foregroundColor(.green ) }
Replies
Boosts
Views
Activity
Dec ’24
Reply to cannot find text1 in scope
I was asked to send the code where I call detailLine. I did that but I never got the answer. I'm still waiting. Please answer.
Replies
Boosts
Views
Activity
Dec ’24
Reply to cannot find text1 in scope
If I put func detailLine in the curly braces I get another error. I get: Closure containing a declaration cannot be used with result builder 'ViewBuilder' Also I get cannot find detailLine in scope. Please help.
Replies
Boosts
Views
Activity
Dec ’24
Reply to cannot find text1 in scope
Thank you.
Replies
Boosts
Views
Activity
Dec ’24
Reply to Cannot find 'detailline' in scope
I think I solved this one. I just want to make sure I got it right. I put the function right on top of #Preview. No brackets after the function and before #Preview. No errors. Does that sound right?
Replies
Boosts
Views
Activity
Dec ’24
Reply to cannot find in scope
Please help.
Replies
Boosts
Views
Activity
Dec ’24
Reply to Cannot find 'detailline' in scope
Should I mail the link to the test project.
Replies
Boosts
Views
Activity
Dec ’24
Reply to cannot find in scope
Did you find out what's the problem?
Replies
Boosts
Views
Activity
Dec ’24
Reply to cannot find in scope
Yes I call enterp() from a button. But it's not in viewdetail. It's in the main program(var some body). var body: some View { NavigationStack { VStack { Text(" " + Date().formatted(date: .numeric, time: .omitted)) .foregroundColor(.black) .fontWeight(.bold) Text("Driver's Food Delivery") .font(.largeTitle) .fontWeight(.bold) Image("Screenshot 2024") HStack { Text("Cost") .font(.largeTitle) .padding(10) Spacer() Text("Paid") .font(.largeTitle) .padding(10) Spacer() Text("Tip") .font(.title) Spacer() Text("Tip %") .font(.title) } HStack { TextField("Cost", text: $cost) .frame(width: 75, height: 25) .padding(20) .fontWeight(.bold) .font(.system(size: 22)) .foregroundColor(.blue) .background(Color.brown) .cornerRadius(025) TextField("Paid", text: $paid) .frame(width: 75, height: 25) .padding(20) .fontWeight(.bold) .font(.system(size: 22)) .foregroundColor(.blue) .background(Color.brown) .cornerRadius(025) Text(tipp) .frame(width: 95, height: 25) .background(Color.white) .fontWeight(.bold) .font(.system(size: 22)) .foregroundColor(.blue) Text(tipc) .frame(width: 75, height: 5) .padding(10) .background(Color.white) .fontWeight(.bold) .font(.system(size: 22)) .foregroundColor(.blue) } VStack { Text (emsg) .foregroundColor(.red) Text (msg) .foregroundColor(.blue) HStack { Text (msg2) .foregroundColor(.blue) Spacer() } Button { enterp() } label: { Text("Enter") .font(.largeTitle) .foregroundColor(.green ) } I'm going to have text1 to text44. What else do you need to know?
Replies
Boosts
Views
Activity
Dec ’24
Reply to cannot find in scope
func enterp() { var ipc = 50.0 var ipcc = 50.0 var tippp = 0.0 var totalcsh = 0.0 var ttips = 0.0 var tcost = 0.0 var tipo = 0.00 costt = Double(cost) paidt = Double(paid) emsg = "" if (costt != nil) && (paidt != nil) { tipo = (Double(paid)! - Double(cost)!) tipa.append (tipo) costa.append (Double(cost)!) number += 1 numbc = String(number) ttips = (tipa.reduce(0, +)) tcost = (costa.reduce(0,+)) tippp = (ttips / Double(number)) tipaa = tippp.formatted(.currency(code: "USD")) totaltips = ttips.formatted(.currency(code: "USD")) totalcost = tcost.formatted(.currency(code: "USD")) tipp = tipo.formatted(.currency(code: "USD")) tipc = String(tipo / Double(cost)! * 100) ipc = Double (tipc)! tipc = String(format: "%3.0f%%", ipc) tipcc = String(ttips / tcost * 100) ipcc = Double (tipcc)! tipcc = String(format: "%3.0f%%", ipcc) totalcsh = (tcost + ttips) totalcash = totalcsh.formatted(.currency(code: "USD")) } else { emsg = "Enter numbers and 1 decimal point only." } detailLine(costa: &costa,tipa: &tipa) } }
Replies
Boosts
Views
Activity
Dec ’24
Reply to Cannot find 'detailline' in scope
I created the test project. Do you want me to send the link?
Replies
Boosts
Views
Activity
Dec ’24