Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Arrays 使用带有一系列选项的swiftui选择器时。如何将所选选项而不是索引值保存到Cloud Firestore?_Arrays_Firebase_Indexing_Google Cloud Firestore_Swiftui - Fatal编程技术网

Arrays 使用带有一系列选项的swiftui选择器时。如何将所选选项而不是索引值保存到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

我希望能够访问和使用该位置。当前只有选择器中的索引值保存到Cloud Firestore

这是提货员:

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=[”选择器的选择和标识符必须是相同的类型

非常有帮助!非常感谢