简体   繁体   中英

Determine iOS application's total disk usage/filesize

I have an app that allows users to download files and save them to the device's internal memory. I need to be able to display the total app disk usage at any given time. I found how to check the total device disk size and usage, but not specifically the app's disk usage. How would I go about getting that same value that can be seen in the Settings -> Usage screen for the app?

You can use NSFileManager to examine files and directories. Just like with a desktop app, your app has access to its sandbox and the directory and files there. The most likely place you are saving files is in your apps Documents directory, so you can ask NSFileManager to iterate over the contents of that directory for the files you are interested in, and then get attributes (like size) of those files. It's all there in the docs .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM