iPhone: available disk space

前端 未结 3 1429
清酒与你
清酒与你 2021-01-14 14:30

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.

相关标签:
3条回答
  • 2021-01-14 14:37

    This is probably a useful example.

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

    0 讨论(0)
  • 2021-01-14 14:38

    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.

    0 讨论(0)
  • 2021-01-14 14:51

    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.

    0 讨论(0)
提交回复
热议问题