我想在数组数组中搜索一个值,就像在这个例子中一样,但我不知道如何表示它“第一个元素在 $0 中的位置”?
var programArray: [Any] = []
let slots: String = "2021-14-09 08:00:00|2021-14-09 09:00:00|ACCUEIL CAFE|Amphi A#2021-14-09 09:00:00|2021-14-09 10:00:00|PLENIERE|Amphi A#2021-14-09 10:00:00|2021-14-09 12:00:00|WORKSHOP|Salle Besse#2021-14-09 12:00:00|2021-14-09 14:00:00|DEJEUNER|Cantine#2021-14-09 14:00:00|2021-14-09 16:00:00|TESTDRIVES|XXX#2021-14-09 16:00:00|2021-14-09 17:00:00|CLOTURE|Amphi A#"
//Convert Slots in array
let stringArray = slots.components(separatedBy: "#")
if stringArray.count > 1 {
for i in 0..<stringArray.count {
let intermediateTwo = stringArray[i]
let strinArrayTwo = intermediateTwo.components(separatedBy: "|")
if strinArrayTwo.count > 1 {
programArray.append(strinArrayTwo)
} else {
print("not found")
}
}
} else {
print("not found")
}
//Remove other dates than today
let index = programArray.firstIndex(where: {$0 == "2021-14-09"}) //PROBLEM: Cannot convert value of type 'Any' to expected argument type 'String'
//access index here
programArray.remove(at: index)
提前致谢