如何从iOS advertisementData [CBAdvertisementDataServiceDataKey]对象中获取数据?

时间:2016-02-27 21:35:24

标签: ios advertisement bluetooth-lowenergy

I used this code:

func centralManager(centralManager: CBCentralManager, didDiscoverPeripheral peripheral: CBPeripheral, advertisementData: [String : AnyObject], RSSI: NSNumber)
{
        let scannedPeripheral = (peripheral, advertisementData[CBAdvertisementDataServiceDataKey])
        peripherals.append(scannedPeripheral)
        print(advertisementData[CBAdvertisementDataServiceDataKey]!)
        tableView.reloadData()
}

将BLE外设对象及其对应的advertisementData[CBAdvertisementDataServiceDataKey]对象上传到iOS手机。我将两个对象存储为[peripheral, anyObject?]数组中的元组。当我在控制台中打印advertisementData[CBAdvertisementDataServiceDataKey]对象时,我看到了:

{
    "91765580-D821-1000-8000-00805F9B34FB" = <8df0>;
}

应该是具有NSDictionary密钥和CBUUID值的NSData。这些信息正是我所需要的,但我无法在我的程序中使用它。关于如何打破这些数据的任何想法?

0 个答案:

没有答案