I am retrieving file size of PDF file that located in document directory with following codes.
- (NSString *)sizeOfFile:(NSString *)filePath {
NSDictionary *fileAttributes = [[NSFileManager defaultManager] attributesOfItemAtPath:filePath error:nil];
NSInteger fileSize = [[fileAttributes objectForKey:NSFileSize] integerValue];
NSString *fileSizeString = [NSByteCountFormatter stringFromByteCount:fileSize countStyle:NSByteCountFormatterCountStyleFile];
return fileSizeString;
}
NSURL *url = [self.arrayOfBooks objectAtIndex:indexPath.row];
NSLog(@"%@",[self sizeOfFile:url.absoluteString]); // Showing zero KB.
I am sure there is file in arrayBooks
because it can show in cellForRowAtIndexPath
.
But i don't know why file size is showing zero.
Please help me.