title: Core Bluetooth Swift get devices name
body: <p>I'm studying Core Bluetooth framework and I did a test project about it for learning:</p>
  
  <pre><code>class ViewController: UIViewController,CBCentralManagerDelegate,CBPeripheralDelegate {
  
      var centralManager: CBCentralManager = CBCentralManager()
      var peripheral: CBPeripheral? = nil
  
      override func viewDidLoad()
      {
          super.viewDidLoad()
          centralManager = CBCentralManager(delegate: self, queue: nil)
      }
  
      override func didReceiveMemoryWarning()
      {
          super.didReceiveMemoryWarning()
  
      }
  
      func centralManagerDidUpdateState(_ central: CBCentralManager)
      {
          central.scanForPeripherals(withServices: nil, options: nil)
      }
  
      @available(iOS 5.0, *)
      public func centralManager(_ central: CBCentralManager, didDiscover peripheral: CBPeripheral, advertisementData: [String : Any], rssi RSSI: NSNumber)
      {
          let device = (advertisementData as NSDictionary)
              .object(forKey: CBAdvertisementDataLocalNameKey)
              as? NSString
  
          let isMyIphone = device?.contains("iPhone")
  
      }
  }
  </code></pre>
  
  <p>For starting I would like to see Bluetooth name around me, for this reason I have 2 iPhone.
  One I use for execute this 'app' for scanning and I would like to see the name of the other iPhone (in Bluetooth setting is name is 'iPhone'), but when I start scanning the method 'didDiscover' is called but the device constant is nil. 
  Why? What I wrong?</p>