2012-10-11 74 views
1

我想篩選NSArray其中包含的對象是NSDictionary。這NSDictionary裏面又包含NSDictionary篩選NSArray,它包含NSDictionary中的NSDictionary

它看起來像這樣。

[ 
    { 
    Comp_Name =  { 
     text = "Quality Ace #5846-C"; 
    }; 
    ShipTo =   { 
     text = 312025846; 
    }; 
    SoldTo =   { 
     text = 10000081; 
    }; 
    }, 
    { 
    Comp_Name =  { 
     text = "Billington Ace Hardware - 5863K"; 
    }; 
    ShipTo =   { 
     text = 312025863; 
    }; 
    SoldTo =   { 
     text = 10000081; 
    }; 
    } 
] 

我想將此數組過濾爲與「Comp_Name」對象匹配的某些「文本」。我使用

代碼是:

_filteredList = [_unFilteredArray filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"Comp_Name == %@", searchBar.text]]; 

請幫我獲得基於對象「COMP_NAME」,「文本」過濾名單。

+2

謂詞不應該是@「Comp_Name.text ==%@」嗎? – rmaddy

+0

我也試過。似乎沒有工作。作爲結果,我得到一個空數組。 –

+0

也許這是字符串周圍缺少的引號。使用@「Comp_Name.text =='%@'」。 – rmaddy

回答

0

@rmaddy - 感謝您的幫助! @"Comp_Name.text == %@"工作得很好。