TableViewにRingtonesディレクトリの内容を一覧表示しようとしていますが、セルごとのファイルではなく、すべてのセルのディレクトリの最後のファイルしか取得していません。これは私のコードです:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
Profile_ManagerAppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
cell.hidesAccessoryWhenEditing = YES;
}
cell.accessoryType = UITableViewCellAccessoryNone;
//cell.textLabel.text = @"No Ringtones";
//cell.textLabel.text = @"Test";
NSString *theFiles;
NSFileManager *manager = [NSFileManager defaultManager];
NSArray *fileList = [manager directoryContentsAtPath:@"/Test"];
for (NSString *s in fileList){
theFiles = s;
}
cell.textLabel.text = theFiles;
return cell;
}
正常に読み込まれ、エラーは発生しません。使用するNSLog
と、ディレクトリ内のすべてのファイルが正常に一覧表示されます。試し[s objectAtIndex:indexPath.row]
ましたが、objectAtIndex:エラーが発生します。誰かアイデアはありますか?