Hi,
I haven't been doing Swift for years, but being old (I started designing computer systems in 1967) and housebound its thought of a simple flying app.I'm deeply impressed with SwiftUI - its a revolution. Anyway I'm having trouble with compiling an enum through a ForEach. Whilst its similar to the one I saw in AvocadoToast, I cannot get it to compile.
I have a model file:
import protocol SwiftWebUI.Identifiable
struct TimePeriod
{
var turning = false
var interval = Interval.eight
}
enum Interval: CaseIterable, Hashable, Identifiable
{
case six, eight, ten, twelve
var name: String { return "(self)".capitalized }
}
And the view file:
struct ContentView: View
{
@State var timePeriod: TimePeriod
var body: some View
{
Form
{
Section(header: Text("Time period").font(.title))
{
Picker(selection: $timePeriod.interval, label: Text("Seconds"))
{
ForEach(Interval.allCases)//error:Cannot convert value of type '[Interval]' to expected argument type 'Range'
{
interval in Text(interval.name).tag(interval) //error: Value of type 'Int' has no member 'name'
}
}
}
Section(header: Text("Turn indicator").font(.title))
{
Text("Angle")
}
}