使用设备可用空间和沙箱空间 [英] Device free space and sandbox space used
本文介绍了使用设备可用空间和沙箱空间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试获取设备上的可用空间以及我的沙箱使用的空间量。有什么想法?
I'm trying to get the free space on the device and the amount of space my sandbox is using. Any thoughts?
谢谢,
Rick
Thanks, Rick
推荐答案
在Objective-C中,您可以使用 NSFileManager
获取可用的文件系统空间:
In Objective-C you can get the available file system space with NSFileManager
:
NSFileManager* filemgr = [NSFileManager defaultManager];
NSArray* paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *docDirectory = [paths objectAtIndex:0];
NSDictionary* fsAttr = [filemgr attributesOfFileSystemForPath:docDirectory error:NULL];
unsigned long long freeSize = [(NSNumber*)[fsAttr objectForKey:NSFileSystemFreeSize] unsignedLongLongValue];
要获得您的应用使用的空间量,请阅读以下问题:
计算文件夹的大小
To get the amount of space your app is using read this question: Calculate the size of a folder
这篇关于使用设备可用空间和沙箱空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文