0

我已经工作了几天了,但没有运气。我正在尝试从 NSDicitonary 解析键/值对的集合,但它似乎对键名中的连字符非常敏感。下面是数据示例。如果我尝试使用下面的代码访问带有连字符的任何字段,则会收到以下错误:

无法识别的选择器发送到实例

有什么建议么?

NSString *param = [[NSString alloc] initWithFormat:@" url-name like %@",url ];   
NSPredicate *predicate = [NSPredicate predicateWithFormat:param]; 
NSArray *results = [aCompanies filteredArrayUsingPredicate:predicate];

<company>
    <address-one></address-one>
    <address-two></address-two>   
    <city></city>
    <country></country>
    <id type="integer">11899</id>
    <name>Aceara</name>
    <phone-number-fax></phone-number-fax>
    <phone-number-office></phone-number-office>
    <state></state>
    <time-zone-id>Central Time (US &amp; Canada)</time-zone-id>
    <url-name>ACEARA</url-name>
    <uuid>7cc52da5-6783-4c59-9c60-b8fe96f2110c</uuid>
    <web-address>WWW.ACEARA.COM</web-address>
    <zip></zip>    
    <can-see-private type="boolean">false</can-see-private>
</company>
4

1 回答 1

3

用引号将字符串括起来以避免出现问题,例如:

initWithFormat:@"'url-name' like '%@'"
于 2009-11-19T23:56:06.390 回答