LLDebugTool
LLDebugTool copied to clipboard
目前获取磁盘剩余空间的方法可能会不太准确
可以尝试一下下面的方法
unsigned long long totalFreeSpace = 0; if (@available(iOS 11.0, *)) {
NSURL *fileURL = [[NSURL alloc] initFileURLWithPath:NSTemporaryDirectory()];
NSDictionary *results = [fileURL resourceValuesForKeys:@[NSURLVolumeAvailableCapacityForImportantUsageKey] error:nil];
totalFreeSpace = [results[NSURLVolumeAvailableCapacityForImportantUsageKey] longLongValue];
}else {
NSDictionary *fattributes = [[NSFileManager defaultManager] attributesOfFileSystemForPath:NSHomeDirectory() error:nil];
totalFreeSpace = [[fattributes objectForKey:NSFileSystemFreeSize] unsignedLongLongValue];
}
return totalFreeSpace;