Xcode UITable未填充NSMutableArray

Xcode UITable未填充NSMutableArray,xcode,nsarray,uitableview,Xcode,Nsarray,Uitableview,在我的应用程序中,我有一个文本字段,如果我输入一个单词,我应该将所有以特定单词开头的文件名输入UITable。在这里,我将这些文件名放入一个数组中,它也可以在NSLog中使用。。。但是桌子总是空的。控件未进入表(未显示NSLog in tables方法)。有人能帮我吗? 我的代码是 -(IBAction)Do_Search:(id)sender { files = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:

在我的应用程序中,我有一个文本字段,如果我输入一个单词,我应该将所有以特定单词开头的文件名输入UITable。在这里,我将这些文件名放入一个数组中,它也可以在NSLog中使用。。。但是桌子总是空的。控件未进入表(未显示NSLog in tables方法)。有人能帮我吗? 我的代码是

-(IBAction)Do_Search:(id)sender
{ 
 files = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:
         [[NSBundle mainBundle] bundlePath] error:nil];
search_results_array = [files filteredArrayUsingPredicate:
                        [NSPredicate predicateWithFormat:@"self BEGINSWITH[cd] 'h'"]];
NSLog(@"%@", search_results_array);
int search_res_count=[search_results_array count];
NSLog(@"Array has %d results...",search_res_count);
[Result_table reloadData];
}
在这里,我无法实现我想要的搜索。相反,我尝试列出所有以“h”开头的文件名

//自定义表格视图单元格的外观

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

static NSString *CellIdentifier = @"Cell";

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
    cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
}

// Set up the cell...
NSString *Lyrics_found= [search_results_array objectAtIndex:indexPath.row];
cell.textLabel.text=Lyrics_found;
NSLog(@"%@",search_results_array);
return cell;
}

当[结果_表重新加载数据];如果给定的程序退出,当删除它时,表仍为空。

保留
搜索结果\u数组
之前
[Result\u table reloadData]
[Result\u table reloadData]之前保留
搜索结果\u数组

在[结果表重新加载数据]之前保留搜索结果数组;誓言太棒了非常感谢。。。它有效…:)如果您的代码崩溃,请在问题中包含崩溃的详细信息。这是非常重要的,但它并没有给出坠机的细节。可能是因为我没有保留数组。现在,在[Result_table reloadData]之前的搜索结果数组中加入它的fineetAt;誓言太棒了非常感谢。。。它有效…:)如果您的代码崩溃,请在问题中包含崩溃的详细信息。这是非常重要的,但它并没有给出坠机的细节。可能是因为我没有保留数组。现在好了
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
 {

static NSString *CellIdentifier = @"Cell";

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
    cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
}

// Set up the cell...
NSString *Lyrics_found= [search_results_array objectAtIndex:indexPath.row];
cell.textLabel.text=Lyrics_found;
NSLog(@"%@",search_results_array);
return cell;
}