我需要篩選聯繫人列表,但不能複製一定數量的字母后附加篩選器損壞的示例圖像和NSPredicate
我是使用。您好,我需要篩選聯繫人列表,但是NSPredicate不起作用
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"CAST(SELF.compositeName, 'NSString') contains[cd] %@",self.SearchNames.text];
我需要篩選聯繫人列表,但不能複製一定數量的字母后附加篩選器損壞的示例圖像和NSPredicate
我是使用。您好,我需要篩選聯繫人列表,但是NSPredicate不起作用
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"CAST(SELF.compositeName, 'NSString') contains[cd] %@",self.SearchNames.text];
第一件事情,你必須使用NSPredicate
的濾鏡陣列。你可以按照下面的鏈接來過濾數組。
在這種鏈路,存在用於使用利用NSPredicate
濾波陣列許多例子。
這裏array
的意思是,它用於顯示在UITableView
。
您還有任何問題,請將您使用過的數組代碼發佈。
試試這個
NSPredicate *predicate = [NSPredicate predicateWithFormat: @"compositeName CONTAINS[c] %@", searchText];
你謂詞的語法是錯誤的。
let predicate = NSPredicate(format: "SELF.compositeName CONTAINS[cd] %@", searchText)
let filtredArray = NSArray(array: YourContactarray.filteredArrayUsingPredicate(predicate))
當我們處理字典數組時,只需SELF.key
對謂詞有效。
此代碼重新載入您的表格後,您可以將其存儲在另一個陣列中進行全局訪問。如果您在此代碼中遇到任何問題,請告訴我。
英文,請。真的很難弄清楚你在說什麼。 – Avi
這是什麼意思「但不要複製一定數量的字母附加過濾器後」。 –
我在對象中使用數組:NSPredicate * predicate = [NSPredicate predicateWithFormat:@「SELF.compositeName,'NSString')==%@」,self.SearchNames.text]; (NSString * key in self.ContactsSectionTitles) { NSArray * result = [self.arrContacts objectForKey:key]; NSArray * matches = [result filteredArrayUsingPredicate:predicate]; if(matches.count> 1) { [self.FilteredNames addObject:matches]; } } –