I am retrieving the size of all files in the document directory. I am using the method attributesOfItemAtPath
to do so. It is successful. But I am getting the output in the form of bytes and of class NSNumber
. It does'nt look good.
So, I need to get the output in KBs or MBs and I have to convert them into NSString
in order to store that in a NSDictionary
as I have to display it in a TableView. Please help me to do so. Thank you.
Here is my code..
directoryContent = [[NSMutableArray alloc] init];
for (NSString *path in paths){
filesDictionary =[[NSMutableDictionary alloc] init];
filesSize = [[NSNumber alloc] init];
filesSize = [filesDictionary objectForKey:NSFileSize];
filesDictionary = [NSDictionary dictionaryWithObjectsAndKeys:filesSize, @"filesSize", nil];
[directoryContent addObject:[filesDictionary copy]];
}
And I am using the following code to bind the size in tableView which is not working.
cell.lblSize.text = (NSString *) [[directoryContent objectAtIndex:listIndex] objectForKey:@"filesSize"];
Help me to convert the size of a file from byte to KiloByte and to display it in a tableView. Thank you in advance..