title: iOS Bluetooth Connect Callback No Longer Works
body: <p>I had a working BLE app, even archived multiple working versions of it.  All of a sudden I am not receiving the callback when a device is connected. I connect to the periperal when the user taps an entry in a ListView of scanned for devices. Another strange thing is that while analyzing the problem I started with a situation where the connect call is issued, the call back received and then an immediate disconnect call back happens.  So I did a project clean and rebuild.  Then the connect call back stopped being invoked entirely.  I went back to known working versions of the app and they do the same thing (connect call back not happening). Today I was pushed updates to the OS and Xcode on both the iPad and Mac but the same thing happens.  Any help would be appreciated.</p>
  
  <pre><code>class ViewController: UIViewController, UITableViewDataSource, UITableViewDelegate, CBCentralManagerDelegate, CBPeripheralDelegate, UITextFieldDelegate
  {
  
  var btManager:    CBCentralManager!
  var btDeviceList: [CBPeripheral] = []
  var btDevice:     CBPeripheral!
  
  
  func centralManager(_ central: CBCentralManager, didDiscover peripheral: CBPeripheral, advertisementData: [String : Any], rssi RSSI: NSNumber)
  {
      print("Found BLE device: " + peripheral.name!);
  
      // Add the scanner only if its not there already
      var i = 0
      var foundIt = false
  
      for tempDevice in btDeviceList
      {
          if tempDevice.identifier == peripheral.identifier
          {
              foundIt = true
              break
          }
  
          i = i + 1
      }
  
      if (!foundIt)
      {
          btDeviceList.append(peripheral)
  
          btListView.reloadData()
      }
  }
  
  // Called when connected to a BLE device
  func centralManager(_ central: CBCentralManager, didConnect peripheral: CBPeripheral)
  {
      print("Connected to: " + peripheral.name!)
  
      // Discover the services for the device
      peripheral.discoverServices(nil)
  }
  
  // Called when a row in the table list view is tapped
  func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath)
  {
      btManager.stopScan()
  
      btDevice = btDeviceList[indexPath.row]
  
      btDevice.delegate = self
  
      print("Connecting to: " + btDevice.name!)
      btManager.connect(btDevice, options: nil)
  }
  
  } // View Controller
  </code></pre>