我想帮助提取字典的内容:
advertisementData[kCBAdvDataManufacturer]
advertisementData
是iOS在BLE扫描期间找到广告BLE服务器时返回的参数之一。
我看到它的类型为AnyObject
。当我打印它时,我可以看到<>中包含的第一个字符。
如何提取剩余的字节内容?
答案 0 :(得分:0)
很可能你需要转换为String
let manufacturerName = advertisementData[kCBAdvDataManufacturer]! as String
println("The manufacturer is \(manufacturerName).")
答案 1 :(得分:0)
Swift 3
let manufactureData = ((advertisementData as NSDictionary).value(forKey: "kCBAdvDataManufacturer")) as? String
print(manufactureData)