美文网首页swift
iOS Swift删除移除数组Array的元素对象

iOS Swift删除移除数组Array的元素对象

作者: Lee坚武 | 来源:发表于2022-01-26 16:21 被阅读0次

更多方法交流可以家魏鑫:lixiaowu1129,一起探讨iOS相关技术!

在Swift中数组Array没有removeObject的方法

1、找到下标

 let model_index = selectedArray.index(where: { (arr) -> Bool in

   ((selectedBeaconArray.index(of: vbModel)) != nil)

 })

2、删除下标对应的元素

if model_index != nil{

  selectedBeaconArray.remove(at: model_index ?? 0)

}

相关文章

网友评论

    本文标题:iOS Swift删除移除数组Array的元素对象

    本文链接:https://www.haomeiwen.com/subject/pdmnhrtx.html