0
我必須使用UISearchBar在數組中搜索單詞。例如,我在索引2的數組中有「Chicken Salad」字符串。現在,如果要用最後一個單詞「Salad」搜索它,那麼我應該怎麼做? 當時我使用這段代碼,它運作良好,但如果你從第一個字搜索。如何使用UISearchBar在數組的字符串中搜索第二個單詞?
(appDelegate.isAirlineSelection == YES) {
for (int i = 0; i < [menuArray count]; i++) {
if ([[[[menuArray objectAtIndex:i] itemName] uppercaseString] hasPrefix:search]||[[[[menuArray objectAtIndex:i] itemName] uppercaseString] hasSuffix:search]) {
[tableMenuArray addObject:[menuArray objectAtIndex:i]];
NSLog(@"Found");
}
}
請幫我
使用NSPredicate進行搜索 – Narayana