如何在NSDictionary中检查字符串的前缀?

时间:2017-06-02 11:30:08

标签: objective-c nsarray nsdictionary

advertisementData包含:

Advertisement data {
    kCBAdvDataIsConnectable = 1;
    kCBAdvDataLocalName = "Ali \n";
    kCBAdvDataServiceUUIDs =     (
        "43200-B827-EB74-0E24-192168001107"
    );
}    
if(advertisementData[@"kCBAdvDataServiceUUIDs"] hasPrefix:@"432"){
    NSLog("It contains this string");
    }

当我执行代码时,它给了我错误: 因未捕获的异常'NSInvalidArgumentException'而终止应用程序,原因:' - [CBUUID hasPrefix:]:无法识别的选择器发送到实例0x170034260'。

1 个答案:

答案 0 :(得分:2)

kCBAdvDataServiceUUIDs是CBUUID。使用uuidString获取字符串。