Search code examples
objective-cuitableviewnsfilemanager

Fill UITableViewCell with objects of a path -> NSFileManager


Is it possible to fill the UITableViewCells with objects of a path? Maybe it could be realizable to click into the cell/ filefolder and open it. So the user can enter in the hierarchy of the file folder

In this case I think about the use of NSFileManager (or is it better working with Core Data, because the files have heavy data requirements?)

Somehow it should be possible to write some code like

- (void)viewDidLoad {
    [super viewDidLoad];

    NSFileManager* fileManager= [[NSFileManager alloc]init];
    myArray= [[NSMutableArray alloc]initWithObjects: 
[fileManager contentsOfDirectoryAtPath: @"~/Desktop/photoAlbum"error:nil],nil];

    self.navigationItem.title= @"All Albums";
}

This line is just an idea, I test it but it shows no content.

Nevertheless should this line represent what I am trying to do as the case may be what I am searching for.

I asked an advanced programmer, and he told me that he had never experienced filling cells with paths. And edited that it is convertible

Thank you for any helps and speculations

EDIT

For everyone who had the same idea.
It is only possible with core data or a web server (web server, we need to have internet)
While I'am at it: Thank you for all speculations :)


Solution

  • This NSFileManager method provides all files at particular path:

    - (NSArray *)contentsOfDirectoryAtPath:(NSString *)path error:(NSError **)error 
    

    Now you have an array that can be used as datasource for a UITableView and fill data according to your requirement.