iPhone: available disk space

折月煮酒 提交于 2019-12-30 10:33:15

问题


I am creating an audio-recording application and I need to know how much disk space is available (not ram).

How can I retrieve it?

Thanks.


回答1:


I haven't tried this, but since the iPhone is a UNIX based OS you should be able to get the free space on the flash file system using the statfs system call (see link for documentation).

Just use as parameter the path to the app directory that you plan to write to.




回答2:


Best solution for me is to use the NSFileManager method:

- (NSDictionary *)attributesOfFileSystemForPath:(NSString *)path error:(NSError **)error

on the directory where you want to save your data. This is a wrapper around the statfs system call, as is mentioned in the docs. But if you're already using NSFileManager, this would be the way to go.




回答3:


This is probably a useful example.

http://kdbdallas.com/2008/12/27/maciphone-show-availble-useable-diskspace/



来源:https://stackoverflow.com/questions/1249014/iphone-available-disk-space

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!