0
我试图从包含在目录的iOS的NSMutableArray坚持
//in my header
@property (strong, nonatomic) NSMutableArray *files;
//in my tableView:cellForRow:atIndexPath:
static NSString *cellid = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellid];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellid];
cell.textLabel.text = [_files objectAtIndex:indexPath.row];
}
return cell;
文件(_files
设置等于[[NSFileManager defaultManager] contentsOfDirectoryAtPath:[self downloadsDir];
之前被调用此方法)这工作数组填充一个UITableView
,并显示正确的文件。 问题是如果我将文件添加到目录中,然后使用tableView reloadData
,则会添加一个新文件,但标题将与另一个文件重复。例如
添加文件othertest.txt
++++++++++++++++++++++++++
text.txt
++++++++++++++++++++++++++
testing.txt
++++++++++++++++++++++++++
testing.txt
++++++++++++++++++++++++++
后
++++++++++++++++++++++++++
text.txt
++++++++++++++++++++++++++
testing.txt
++++++++++++++++++++++++++
表视图中添加文件
前表视图应该++++++++++++++++++++++++++
text.txt
++++++++++++++++++++++++++
testing.txt
++++++++++++++++++++++++++
othertest.txt
++++++++++++++++++++++++++
,如果我重新启动应用程序,它会显示正确的文件。但由于某种原因,它是这样做的。任何人都知道什么可能是错的?
谢谢,这工作。当他们让我时,我会标记它是正确的。 – 2013-04-09 03:11:58
非常普遍的问题。乐意效劳。 – Caleb 2013-04-09 03:12:58