Hi all. I have an mutableArray which displays a list of files in a tableView. I have stored those files in a directory.
I am using
NSfileManager
class and
attributesOfItemAtPath
method to retrieve some properties of the files like fileSize, fileType..
In the second stage I am trying to have a detailView controller which displays the properties of the particular file when touched in the tableView.
The problem is I dont know how to bind those properties like fileSize and fileType separately to a
NSDictionary
and make it display in the detailView for that particular file.
Here is my source code for listing the files and to list the properties.
- (void)listFiles {
NSFileManager *fm =[NSFileManager defaultManager];
NSError *error = nil;
NSString *parentDirectory = @"/Users/akilan/Documents";
NSArray *paths = [fm contentsOfDirectoryAtPath:parentDirectory error:&error];
if (error) {
NSLog(@"%@", [error localizedDescription]);
error = nil;
}
directoryContent = [[NSMutableArray alloc] init];
for (NSString *path in paths){
NSString *documentsDirectory = [[path lastPathComponent] stringByDeletingPathExtension];
[directoryContent addObject:documentsDirectory];
}
}
-(void) willProcessPath {
NSString *parentDirectory = @"/Users/akilan/Documents";
NSArray *paths = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:parentDirectory error:nil];
for (NSString *path in paths){
filesPath = [parentDirectory stringByAppendingPathComponent:path];
NSDictionary *attrDir = [[NSFileManager defaultManager]attributesOfItemAtPath:filesPath error:nil];
filesSize = [attrDir objectForKey:NSFileSize];
filesName = (NSString *)directoryContent;
filesType = [path pathExtension];
createdDate = [attrDir objectForKey:NSFileCreationDate];
modifiedDate = [attrDir objectForKey:NSFileModificationDate];
}
}
Please help me to proceed to the next step.. Thanks in advance..