UISearchBar +对象数组+ NSpredicate

时间:2015-03-05 00:21:41

标签: ios objective-c uitableview

请您告诉我为什么我的SearchBar无法在我的UITableViewController中运行?

-(void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText
{    
NSPredicate *predicate = [NSPredicate
                          predicateWithFormat:@"SELF.TitleInside contains[c] %@",
                          searchText];
filteredArray = [HelpList filteredArrayUsingPredicate:predicate];
}

为什么

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

static NSString *cellIdentifier =@"Cell";
TableViewCell_Rts *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];

if (!cell){
    cell = [[TableViewCell_Rts alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
}

cell.accessoryType = UITableViewCellAccessoryNone;
CellObject *NewIndex = nil;

if (tableView == self.tableView) {
    NewIndex = [HelpList objectAtIndex:indexPath.row];        
    cell.TitleLabel2.text = NewIndex.TitleInside;
    cell.DescriptionLabel2.text = NewIndex.DescriptionInside;

} else {
    NewIndex= [filteredArray objectAtIndex:indexPath.row];
    cell.TitleLabel2.text = NewIndex.TitleInside;
    cell.DescriptionLabel2.text = NewIndex.DescriptionInside;   
}

CellObject是一个NSObject:

@interface CellObject : NSObject
@property (nonatomic, strong) NSString *ImageInside;
@property (nonatomic, strong) NSString *TitleInside;
@end

当我运行应用程序时,我的tableview看起来已填充。然后,当我在搜索栏内写字时,表格不会显示搜索结果。

谢谢¡

0 个答案:

没有答案