我正在嘗試使用filteredArrayUsingPredicate和從.plist文件中的數據構建的數組。不知怎的,它似乎從來沒有過濾我的數組。filteredArrayUsingPredicate不工作
這是我的陣列是如何構建的:
DrillDownAppAppDelegate *AppDelegate = (DrillDownAppAppDelegate *)[[UIApplication sharedApplication] delegate];
self.tableDataSource = [AppDelegate.data objectForKey:@"Rows"];
copyDataSource = [ tableDataSource mutableCopy];
,然後我的謂詞是這樣的,
NSString *searchFor = search.text;
[tableDataSource release];
tableDataSource = [copyDataSource mutableCopy];
if ([searchFor length] > 0) {
NSLog(@"array = %@",tableDataSource);
NSPredicate *pred = [NSPredicate predicateWithFormat:@"Self beginswith[c] %@",searchFor];
[tableDataSource filteredArrayUsingPredicate:pred];
}