0

我具有2个字典阵列撰写。第一部字典按服务分组,并给出了包含我的第二部字典和所有详细信息的阵列中具有相同服务的公司数量。NSpredicate结果

的第一部字典有2个按键公司和服务

内各公司的我有一个包含我的第二个字典,下面的键值

AddressInformation,名称和服务阵列。

我想NSpredicate消除所有公司名称 对象从我的第二个字典,不对应于searchText。现在它的过滤过程只发生在第一个字典上。它不断给我所有从我的第二个字典中的结果,但消除了第一词典(公司和服务)的唯一对象。

预先感谢!

NSPredicate *predicate = [NSPredicate predicateWithFormat:@"ANY %K.%K CONTAINS[cd] %@", 
           @"Companies",@"Name",searchText]; 

    FilteredObject = [NSMutableArray arrayWithArray:[AllDataGroupbyServiceArray 

filteredArrayUsingPredicate:谓词]];

(
    { 
    Companies =   (
        { 
      AddressInformation = h3k2w3; 
      Name = Teg; 
      Service = ""; 
     } 
    ); 
    Services = ""; 
}, 
    { 
    Companies =   (
        { 
      AddressInformation = j9g2k6; 
      Name = Megan; 
      Service = Electrician; 
     }, 
        { 
      AddressInformation = h2k2w3; 
      Name = test; 
      Service = Electrician; 
     }, 
        { 
      AddressInformation = h2t3b3; 
      Name = Janet; 
      Service = Electrician; 
     }, 
        { 
      AddressInformation = "J4J 1H7"; 
      Name = Rick; 
      Service = Electrician; 
     }, 
        { 
      AddressInformation = "H1T 4B6"; 
      Name = Herber; 
      Service = Electrician; 
     }, 
        { 
      AddressInformation = "J0K 3B0"; 
      Name = test; 
      Service = Electrician; 
     }, 
        { 
      AddressInformation = h2k2w3; 
      Name = test; 
      Service = Electrician; 
     }, 
        { 
      AddressInformation = h2k2w3; 
      Name = canada; 
      Service = Electrician; 
     } 
    ); 
    Services = Electrician; 
}, 
    { 
    Companies =   (
        { 
      AddressInformation = J0L2K0; 
      Name = "Colas Bn"; 
      Service = Mason; 
     }, 
        { 
      AddressInformation = J5A1M2; 
      Name = mrnoskill2; 
      Service = Mason; 
     }, 
        { 
      AddressInformation = J0L2K0; 
      Name = test8; 
      Service = Mason; 
     }, 
        { 
      AddressInformation = J5C1S3; 
      Name = test6; 
      Service = Mason; 
     }, 
        { 
      AddressInformation = h3r1z2; 
      Name = Jason; 
      Service = Mason; 
     }, 
        { 
      AddressInformation = j7h2k7; 
      Name = max; 
      Service = Mason; 
     }, 
        { 
      AddressInformation = J5Z2W5; 
      Name = Fred; 
      Service = Mason; 
     }, 
        { 
      AddressInformation = "H4G 1K6"; 
      Name = Joe; 
      Service = Mason; 
     }, 
        { 
      AddressInformation = j3y7a6; 
      Name = Tets; 
      Service = Mason; 
     } 
    ); 
    Services = Mason; 
}, 
    { 
    Companies =   (
        { 
      AddressInformation = h2k2w3; 
      Name = jake; 
      Service = Plumber; 
     } 
    ); 
    Services = Plumber; 
} 
) 

回答

0

而不是使用predicateWithFormat:,尽量predicateWithBlock:。这使您可以完全控制用于测试每个条目的过程。

另外我会建议你的模型很奇怪。你可能需要一个更适合你的数据模型的结构。

相关问题