-
Notifications
You must be signed in to change notification settings - Fork 124
Open
Description
可以尝试一下下面的方法
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;
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels