I\'m using Xcode 11 beta 5 and what I had it doesn\'t work anymore. This is my code:
struct ModeView : View {
@EnvironmentObject var state: IntentionState
v
ForEach
syntax changed a little bit in Beta 5.
Have you tried:
ForEach(state.modes, id: \.self) { mode in
Text(mode)
}
let suppose you have a name array like this:
let names = ["mike","Jack","jill"]
ForEach(names, id: \.self) { Text($0) }
Text($0)
- this will print all elements from your names array.
Note:
Use
backslashsign.self
instead.self
, somehow backslash sign is not working here
As per the apple release note, it's known issue from their end. We have to wait for another release.
https://developer.apple.com/documentation/ios_ipados_release_notes/ios_ipados_13_beta_5_release_notes
The identified(by:)
method has been deprecated, the correct syntax is now:
init(Data, id: KeyPath<Data.Element, ID>, content: (Data.Element) -> Content)
or after moving the content into a closure :
ForEach(state.modes, id: \.self) { mode in Text(mode) }