SegmentedControl has this weird behaviour in beta 4:
The following does work and allows player A, B or C to be selected:
var players = {
[Player("A"), Player("B"), Player("C")]
}
SegmentedControl(selection: $game.master) {
// BTW, why does beta 4 require players to have the extra ()?
ForEach(0 ..< self.players().count) {
Text(self.players()[$0].name).tag($0)
}
}
The following does allow player A, B or C to be selected, or none:
SegmentedControl(selection: $game.master) {
ForEach(0 ..< self.players().count) {
Text(self.players()[$0].name).tag($0)
}
Text("none").tag(self.players().count)
}
The following does allow player B or C to be selected, but when trying to select A, the selection switches to "none" (you have to set a breakpoint to see the flip between A and "none"):
SegmentedControl(selection: $game.master) {
Text("none").tag(0)
ForEach(0 ..< self.players().count) {
Text(self.players()[$0].name).tag($0+1)
}
}