NSLog打印出来的尖括号是什么类型?
NSLog打印出来的如下图:
advertisementData[@"kCBAdvDataServiceData"][@"B000"]
取不到尖括号这一部分的值,感觉是类型的问题,百度、Google了半天也没找到答案,请大牛来帮忙,感谢!
回答:
昨天晚上找到的解决办法:
NSString *serviceData = [advertisementData[@"kCBAdvDataServiceData"] description];NSString *MACString = [serviceData substringWithRange:NSMakeRange(14, 13)];
今天看到CBAdvertisementDataServiceDataKey的注释中说key是CBUUID
对象,改成下面的代码了,value是NSData
对象
NSDictionary *serviceData = advertisementData[CBAdvertisementDataServiceDataKey];NSData *MACData = serviceData[[CBUUID UUIDWithString:@"B000"]];
NSString *MACString = [MACData description];
下午再次改进
NSDictionary *serviceData = advertisementData[CBAdvertisementDataServiceDataKey];NSData *MACData = serviceData[[CBUUID UUIDWithString:@"B000"]];
Byte *MACDataByte = (Byte *)MACData.bytes;
NSMutableString *MAC = [NSMutableString stringWithString:@""];
for(int i = 0; i < [MACData length]; i++) {
if (i > 0) {
[MAC appendString:@":"];
}
[MAC appendString:[NSString stringWithFormat:@"%x", MACDataByte[i]]];
}
以上是 NSLog打印出来的尖括号是什么类型? 的全部内容, 来源链接: utcz.com/p/187013.html