我有一个整数数组,想要创建一个函数从数组中删除某个特定的值。然而,removeAtIndex() 函数只能删除第一次出现的值,removeLast() 只能删除最后一个值。我尝试通过枚举数组来解决问题,但最终遇到了“Array index out of range”错误,可能是由于在从数组中删除项时发生了重新排列。
for (index, value) in connectionTypeIDs.enumerate() {
if (value == connectionTypeToDelete){
connectionTypeIDs.removeAtIndex(index)
}
}
有没有关于如何实现这个的想法?