I want to display fileNames , types , size ... in a table view. I've tried to display the file names.the table view is filled by data but they are not displayed. A warning is shown : 'directoryContectsAtPath:' is deprecated. Here is the code (.m file). help please
@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
To avoid the deprecation warning, you can use
[[NSFileManager defaultManager] contentsOfDirectoryAtPath: error:nil]
instead of
[[NSFileManager defaultManager]directoryContentsAtPath:@"/"]
Also, you have a typo in method (tableView, not tableWiew)
-(id)tableWiew:(NSTableView *)uploadTable objectValueForTableColumn:(NSTableColumn *)tableColumn row:(int)row