2014-04-07 170 views
0

在地址簿類應用程序上做項目。我需要預測地址簿聯繫人,結果如下所示預測嵌套陣列

(
{ 
AddressKey =  (
); 
Email =  (
); 
"JobTitle_Name" = ""; 
"Organisation_Name" = ""; 
Phone =  (
      { 
     phoneNumber = "+919502266633"; 
     "phone_type" = home; 
    }, 
      { 
     phoneNumber = 9703570333; 
     "phone_type" = work; 
    }, 
      { 
     phoneNumber = 91234512345; 
     "phone_type" = iPhone; 
    }, 
      { 
     phoneNumber = 91239123; 
     "phone_type" = mobile; 
    } 
); 
"first_name" = Raviraja; 
imageKey = ""; 
"last_name" = ""; 
serialNumberKey = 53; 
source = Device; 
} 
) 

需要使用phoneNumber鍵來判斷數組。我試過這一個

 NSPredicate *predicate = [NSPredicate predicateWithFormat:@"ANY %K == %@",@"phoneNumber",[NSString stringWithFormat:@"%@",str]]; 
     NSArray *array = [contactsArray filteredArrayUsingPredicate:predicate]; 

但不工作eventhough電話號碼匹配。

幫幫我吧。

+0

注意您可以替換'[的NSString stringWithFormat:@ 「%@」,STR]'只需'str'。 –

回答

1

的關鍵路徑是錯誤的,它應該是

[NSPredicate predicateWithFormat:@"ANY %K == %@",@"Phone.phoneNumber", ...] 
+0

我愛你的兄弟..這麼簡單。有點後悔,給我的郵件ID,我結節教我的人 – Joker