I'm using an ObservableObject 'DataStore', which contains an array ('exampleList') of objects ('exampleObject').
@Published exampleList = [exampleObject]()
I'm calling the DataStore via @EnvironmentObject ('dataStore').
@EnvironmentObject var dataStore = DataStore()
Then I iterate the list with
ForEach(0..<dataStore.exampleList.count) { index in ....
To bind element of item to a detail view, I'm doing like this:
DetailView(itemBinding: $dataStore.exampleList[index])
Until Xcode11 beta 4, it worked perfectly. Since XCode11 beta 5, it still works but Xcode gives me this alert:
'subscript(_:)' is deprecated: See Release Notes for a migration path
I tried with simpler stuff, with a simple @State var containing an array of strings, and it's the same issue: when calling an element of this array, and trying to use the value into a TextField:
TextField("test", text: $test[0])
I get the same alert.
I don't understand how to fix it. Does that mean that we no longer can bind values inside an array?
Then, how can we iterate an array and bind a specific item?
This is my first question on Stack Overflow, I apologize if my question is clumsy...
Thanks a lot for your answers, I'm using Stack Overflow for years, it's amazing, I always find existing and helpful answers, but it is the first time I can't find any, that's why I'm asking.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…