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)

}


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM