Arrays 使用带有一系列选项的swiftui选择器时。如何将所选选项而不是索引值保存到Cloud Firestore?
我希望能够访问和使用该位置。当前只有选择器中的索引值保存到Cloud Firestore 这是提货员:Arrays 使用带有一系列选项的swiftui选择器时。如何将所选选项而不是索引值保存到Cloud Firestore?,arrays,firebase,indexing,google-cloud-firestore,swiftui,Arrays,Firebase,Indexing,Google Cloud Firestore,Swiftui,我希望能够访问和使用该位置。当前只有选择器中的索引值保存到Cloud Firestore 这是提货员: Picker(selection: $viewModel.injury.locationIndex, label: Text("General Location")) { ForEach(0 ..< locationOptions.count) { Text(self.locationOptions[$0]) } Picker(选择:$viewModel
Picker(selection: $viewModel.injury.locationIndex, label: Text("General Location")) {
ForEach(0 ..< locationOptions.count) {
Text(self.locationOptions[$0])
}
Picker(选择:$viewModel.injury.locationIndex,标签:文本(“一般位置”)){
ForEach(0..
以下是阵列:
var locationOptions = ["The selection and identifier of Picker have to be same type. So you would have something like
Picker(selection: $viewModel.injury.specificLocation, label: Text("General Location")) {
ForEach(locationOptions, id: \.self) {
Text($0)
}
var locationOptions=[”选择器的选择和标识符必须是相同的类型
非常有帮助!非常感谢