2016-04-02 101 views
2

我有一個NSMutableArray它有幾個像這樣的字典對象。如何使用謂詞在NSMutableArray上搜索某些東西

"DisplayName": "ART42 - Jomon Williams", 
    "DisplayName2": "Jomon Williams", 
    "EmployeeNumber": "ART42", 
    "Designation": "Senior Executive - Systems", 

我有一個UITextField時,其文字改變我想重裝我UITableView與搜索過濾陣列。爲了搜索,我做了這樣的事情。當我的文字正在改變時,我會這樣做。

NSPredicate *exists = [NSPredicate predicateWithFormat:@"SELF CONTAINS[cd] %@", searchText]; 
    NSLog(@"Predicate-------%@",exists); 

    NSArray *aList = [mutArrayStaff filteredArrayUsingPredicate:exists]; 

我想通過DisplayName2鍵搜索。每次我的aList數組都是空的。如何正確書寫我的謂詞,以便搜索DisplayName2

請幫助我。 感謝

+0

你得到解決? – user3182143

回答

3

假設mutArrayStaff是字典列表,每個包含DisplayName2的關鍵人,你可以做到以下幾點:

NSPredicate *exists = [NSPredicate predicateWithFormat:@"(DisplayName2 CONTAINS[cd] %@)", searchText]; 
相關問題