progress bar will not work

progress bar will not work in swiftUI here is the code I used.
Code Block
import SwiftUI
struct ContentView: View {
    @State private var progress = 0
   
    var body: some View {
        
        ProgressView(value: $progress)
        }
          
         
    }
            
         
struct ContentView_Previews: PreviewProvider {
    static var previews: some View {
        ContentView()
    }
}
    


Answered by OOPer in 663246022

Initializer 'init(value:total:)' requires that 'Binding<Int>' conform to 'BinaryFloatingPoint'

Thanks for showing the error message. That will help readers find what's happening in your code.

The initializer of ProgressView you are trying has this signature:
Code Block
init<V>(value: V?, total: V = 1.0) where Label == EmptyView, CurrentValueLabel == EmptyView, V : BinaryFloatingPoint

The value passed to value: needs to be of some type BinaryFloatingPoint, not Binding nor Int.

Code Block
struct ContentView: View {
@State private var progress: Double = 0 //<- A type conforming to `BinaryFloatingPoint`
var body: some View {
ProgressView(value: progress) //<- No `$` here
}
}


What do you mean by will not work?
  • If your code causes build time errors, you should show all the error messages.

  • If your code causes runtime errors, you should include all the error info as well as all the steps to reproduce the error.

  • If your code runs without errors but generates unexpected results, you need to clarify what you expect, what you actually get and how you can reproduce the issue.

there is a error that keeps popping up on line 17.

there is a error that keeps popping up on line 17.

you should show all the error messages.


here is the error message there is only one. Initializer 'init(value:total:)' requires that 'Binding<Int>' conform to 'BinaryFloatingPoint'
Accepted Answer

Initializer 'init(value:total:)' requires that 'Binding<Int>' conform to 'BinaryFloatingPoint'

Thanks for showing the error message. That will help readers find what's happening in your code.

The initializer of ProgressView you are trying has this signature:
Code Block
init<V>(value: V?, total: V = 1.0) where Label == EmptyView, CurrentValueLabel == EmptyView, V : BinaryFloatingPoint

The value passed to value: needs to be of some type BinaryFloatingPoint, not Binding nor Int.

Code Block
struct ContentView: View {
@State private var progress: Double = 0 //<- A type conforming to `BinaryFloatingPoint`
var body: some View {
ProgressView(value: progress) //<- No `$` here
}
}


Thanks.
progress bar will not work
 
 
Q