如何获取列表中选定行的值?
例如:
var data: [String] = []
List {
ForEach(0..<data.count, id: \.self) { item in
HStack {
Text(data[item])
}
}
} //: End of the List
.onDelete(perform: { indexSet in
// get the value of the row
// get the corresponding key for the value
// delete the value by the key from the dictionary
}) //: End of the onDelete
.onAppear {
let dictionary = //retrieve the data from the database and get a dictionary
for entry in dictionary {
data.append(entry.value)
}
} //: End of the onAppear
如何获取列表中选定行的值?