lundi 6 septembre 2021

How to set a custom random range in SwiftUI/Swift

I need to create a custom range for random int in SwiftUI (or Swift).

Now I have two custom ints (minValue & maxValue, I will set them using TextField). So mainNum need to be ranged by them. I thought this would work, but no

@State var minValue: Int = 0
@State var maxValue: Int = 100
@State var mainNum: Int = Int.random(in: minValue...maxValue)



Aucun commentaire:

Enregistrer un commentaire