Swift: How to Remove a Specific CBPeripheral from an Array
To delete a specific 'CBPeripheral' object from the 'peripherals' array, you can use the 'remove(at:)' method. Here's an example:
if let index = peripherals.firstIndex(of: peripheral) {
peripherals.remove(at: index)
}
Replace 'peripheral' with the 'CBPeripheral' object you want to remove. This code checks if the 'peripheral' object exists in the 'peripherals' array and removes it at the found index.
原文地址: https://www.cveoy.top/t/topic/bJFO 著作权归作者所有。请勿转载和采集!