Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using ForEach with a string array - [String] has no member 'identified'

Tags:

swift

swiftui

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

  var body: some View {
      Picker(selection: $state.selection, label: Text("")) {
        ForEach(state.modes.identified(by: \.self)) { mode in
          Text(mode)
        }
      }.pickerStyle(SegmentedPickerStyle())
  }
}

The error is in the line ForEach(uistate.modes.identified(by: \.self)) { mode in and it says:

Value of type '[String]' has no member 'identified'

When I was using Xcode 11 beta 4 it worked perfectly. The question now is how to use ForEach with an array string in Xcode beta 5

like image 998
fdelafuente Avatar asked Jul 28 '26 00:07

fdelafuente


2 Answers

ForEach syntax changed a little bit in Beta 5.

Have you tried:

ForEach(state.modes, id: \.self) { mode in
    Text(mode)
}
like image 138
backslash-f Avatar answered Jul 30 '26 15:07

backslash-f


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

enter image description here

like image 45
Sharad Paghadal Avatar answered Jul 30 '26 14:07

Sharad Paghadal



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!