Post

Replies

Boosts

Views

Activity

Reply to Type of expression is ambiguous without more context
struct CalculatePaceView: View {    @State private var checknewTime = ""     @State private var checknewHour = ""     @State private var checknewMinute = ""     @State private var checknewSeconds = ""     @State private var checknewDistance = ""     @State private var checknewMeters = ""     @State private var checknewKilometers = ""     @State private var checknewMiles = ""     @State private var checknewYards = ""     @State private var checknewPace = ""     @State private var checkperMeter = ""     @State private var checkperKilometer = ""     @State private var checkperMile = ""     @State private var checkperYard = ""    var calculatePace: Double {         guard let newDistance = Double(checknewDistance),               let newTime = Double(checknewTime),               let newMeters = Double(checknewMeters),               let newKilometers = Double(checknewDistance),               let newMiles = Double(checknewMiles),               let newYards = Double(checknewYards),             //  let newPace = Double(checknewPace),               let newHour = Double(checknewHour),               let newMinute = Double(checknewMinute),               let newSeconds = Double(checknewSeconds),               let perMeter = Double(checkperMeter),               let perKilometer = Double(checkperKilometer),               let perMile = Double(checkperMile),               let perYard = Double(checkperYard)               else {                   return 0               }    let NewTime = [newHour, newMinute, newSeconds]         let NewHour = newHour         let NewMinute = newMinute         let NewSeconds = newSeconds         let NewDistance = newDistance         let NewMeter = newMeters         let NewKilometer = newKilometers         let NewMiles = newMiles         let NewYards = newYards         let NewPace = [perMeter, perKilometer, perMile, perYard]         let calculatePace = (Double(NewTime[0]*3600 + NewTime[1]*60 + NewTime[2]) / Double(3600 * NewDistance))         return calculatePace     } } var body: some View {   NavigationView { // error is here     Form {         Group {         List {         VStack {                 NavigationLink(<Text>(VStack {                         ScrollView(.vertical) {                             VStack(spacing: 13) {                                 ForEach(0..<1) {_ in TextField("Enter hour",text:$checknewHour                                                                 .keyboardType(.decimalPad)                                                                 .font(.system(size: 25)), Text("\(checknewHour) $ Hour")                                                                     .foregroundColor(.purple)                                                                     .font(.system(size: 25)),TextField("Enter minute",text:$checknewMinute                                                                                                         .keyboardType(.decimalPad)                                                                                                         .font(.system(size: 25)), Text("\(checknewMinute) $ Minute")                                                                                                             .foregroundColor(.purple)                                                                                                             .font(.system(size: 25)), label: {                              Text("Calculate Pace")                         .bold()                         .frame(width: 280, height: 50)                         .background(Color.init(red: 0.818, green: 0.688, blue: 0.095))                         .foregroundColor(.white)                         .cornerRadius(10)                         .navigationTitle ("Pace Calculator")                         // .navigationBarTitleDisplayMode(.inline)                         .padding(5)                 }                    ))}     }            }
Oct ’21
Reply to Cannot convert value of type '[Double]' to expected argument type 'Double'
let NewTime = [newHour, newMinute, newSeconds]         let NewHour = newHour         let NewMinute = newMinute         let NewSeconds = newSeconds         let NewDistance = newDistance         let NewMeter = newMeters         let NewKilometer = newKilometers         let NewMiles = newMiles         let NewYards = newYards         let NewPace = [perMeter, perKilometer, perMile, perYard]                           let calculatePace = (NewTime / NewDistance)                  return calculatePace     } }
Oct ’21
Reply to Closure containing a declaration cannot be used with result builder 'ViewBuilder'
Again, the error appears : Closure containing a declaration cannot be used with result builder 'ViewBuilder' : struct ContentView_Previews: PreviewProvider { // <- error Closure containing a declaration cannot be used with result builder 'ViewBuilder' and  Struct 'ViewBuilder' declared here (SwiftUI.ViewBuilder)     static var previews: some View {         ContentView()     } }     static var previews: some View {         ContentView()     }        }
Sep ’21