title: how to connect with bluetooth low energy in ios swift?
body: <p>I want to connect with ble peripheral.
  But my code doesn't call didConect function</p>
  
  <p>this is my code :  </p>
  
  <pre><code>func centralManager(_ central: CBCentralManager, didDiscover peripheral: CBPeripheral, advertisementData: [String : Any], rssi RSSI: NSNumber) {
   let device = (advertisementData as NSDictionary)
              .object(forKey: CBAdvertisementDataLocalNameKey)
              as? NSString
  
          if device?.contains(BEAN_NAME) == true {
  
              print("Did discover peripheral", peripheral)
  
              self.bluetoothManager.stopScan()
              self._peripheral = peripheral
              self._peripheral.delegate = self
              central.connect(peripheral, options: nil)
          }
  }
  
  
  func centralManager( central: CBCentralManager, didConnect peripheral: CBPeripheral) { //cant call this
          print("connected to \(BEAN_NAME)")
          peripheral.discoverServices(nil)
      }
  </code></pre>
  
  <p>Logs : </p>
  
  <pre><code>BLE service is powered on
  Did discover peripheral &lt;CBPeripheral: 0x1740eef00, identifier = 4872623B-F872-443A-8A96-F4E1F84D6841, name = GoDoor in  :), state = disconnected&gt;
  </code></pre>