Swift中Array的删除对象

Swift中Array的删除对象

在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)

}

猜你喜欢

转载自www.cnblogs.com/jukaiit/p/10270736.html
今日推荐