Skip to content

Commit

Permalink
Fix Swift 2.2 deprecation warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
kouky committed Apr 3, 2016
1 parent 51a1c69 commit 1692a14
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions BLEFramework/BLE/BLE.swift
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class BLE: NSObject, CBCentralManagerDelegate, CBPeripheralDelegate {

// CBCentralManagerScanOptionAllowDuplicatesKey

NSTimer.scheduledTimerWithTimeInterval(timeout, target: self, selector: Selector("scanTimeout"), userInfo: nil, repeats: false)
NSTimer.scheduledTimerWithTimeInterval(timeout, target: self, selector: #selector(BLE.scanTimeout), userInfo: nil, repeats: false)

let services:[CBUUID] = [CBUUID(string: RBL_SERVICE_UUID)]
self.centralManager.scanForPeripheralsWithServices(services, options: nil)
Expand Down Expand Up @@ -159,19 +159,13 @@ class BLE: NSObject, CBCentralManagerDelegate, CBPeripheralDelegate {
func centralManager(central: CBCentralManager, didDiscoverPeripheral peripheral: CBPeripheral, advertisementData: [String : AnyObject],RSSI: NSNumber) {
print("[DEBUG] Find peripheral: \(peripheral.identifier.UUIDString) RSSI: \(RSSI)")

for var i = 0; i < self.peripherals.count; i++ {

let p = self.peripherals[i] as CBPeripheral

if(p.identifier.UUIDString == peripheral.identifier.UUIDString) {

self.peripherals[i] = peripheral

return
}
}
let index = peripherals.indexOf { $0.identifier.UUIDString == peripheral.identifier.UUIDString }

self.peripherals.append(peripheral)
if let index = index {
peripherals[index] = peripheral
} else {
peripherals.append(peripheral)
}
}

func centralManager(central: CBCentralManager, didFailToConnectPeripheral peripheral: CBPeripheral, error: NSError?) {
Expand Down

0 comments on commit 1692a14

Please sign in to comment.