gpt4 book ai didi

iphone获取可用空间

转载 作者:搜寻专家 更新时间:2023-10-30 20:06:35 24 4
gpt4 key购买 nike

我正在使用此方法获取设备可用空间(在网络上找到):

-(float)getFreeSpace{  
float freeSpace = 0.0f;
NSError *error = nil;
NSDictionary *dictionary = [[NSFileManager defaultManager] attributesOfFileSystemForPath:kSongsFolder error: &error];

if (dictionary) {
NSNumber *fileSystemFreeSizeInBytes = [dictionary objectForKey: NSFileSystemFreeSize];
NSLog(@"%d",fileSystemFreeSizeInBytes);
freeSpace = [fileSystemFreeSizeInBytes floatValue];
} else {
//Handle error
}
return freeSpace/1024;

现在我通过此方法获得 8687616.0,当我检查设备属性时,我有 8.1 GB 的可用空间。

如何获得以 MB 为单位的可用空间?并且这个方法好不好,因为它们之间是有区别的。

最佳答案

fileSystemFreeSizeInBytes/(1024 * 1024) gives you size in MB

关于iphone获取可用空间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10482849/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com