- (unsigned long long)getFreeDiskspace {
unsigned long long totalSpace;
unsigned long long totalFreeSpace;
NSError *error = nil;
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSDictionary *dictionary = [[NSFileManager defaultManager]
attributesOfFileSystemForPath:[paths lastObject]
error:&error];
if (dictionary) {
NSNumber *fileSystemSizeInBytes = [dictionary objectForKey: NSFileSystemSize];
NSNumber *freeFileSystemSizeInBytes = [dictionary objectForKey:NSFileSystemFreeSize];
totalSpace = [fileSystemSizeInBytes unsignedLongLongValue];
totalFreeSpace = [freeFileSystemSizeInBytes unsignedLongLongValue];
NSLog(@"total size:%llu, free size:%llu",totalSpace, totalFreeSpace);
}
return totalFreeSpace;
}
获取ios设备的存储空间当前情况
最新推荐文章于 2021-12-27 17:28:19 发布