0
我想在表格視圖中顯示文件名,類型,大小...。 我試圖顯示文件名稱。表格視圖由數據填充,但不顯示。 顯示警告:不推薦使用'directoryContectsAtPath:'。 這裏是代碼(.m文件)。 幫助,請在目錄nstableview中顯示數據
@implementation TableController
-(void) awakeFromNib{
[uploadTable setDataSource:self];
}
-(IBAction)showFiles:(id)sender{
[fileNames removeAllObjects];
[fileNames autorelease];
fileNames = [[NSMutableArray alloc] initWithArray:[[[NSFileManager defaultManager]directoryContentsAtPath:@"/"]retain]];
[uploadTable reloadData];
}
-(int)numberOfRowsInTableView:(NSTableView *)uploadTable{
return [fileNames count];
}
-(id)tableWiew:(NSTableView *)uploadTable objectValueForTableColumn:(NSTableColumn *)tableColumn row:(int)row{
return [[fileNames objectAtIndex:row] stringValue];
}
@end
使用contentsOf DirectoryAtPath:錯誤:改爲。這在文檔中很容易找到 - 如果您輸入折舊方法的名稱並轉到該鏈接,它通常會說明使用哪種替代方法。 – rdelmar 2012-08-08 14:48:12