简体   繁体   中英

NSFileManager how to know if a file is being used (to avoid deleting it) NSFileBusy?

I'm trying to limit the space used by my iOS app and thus delete old pictures if a limit is reached. However old picture doesn't mean unused picture. I was wondering if there's a way to know if a picture is being used or has been loaded recently to avoid deleting it and thus avoid provoking an app crash. I'm using NSFileManager removeItemAtPath . Thanks!

Any one has more info than the doc on NSFileBusy ?

You can get the fileModificationDate from the files attributes, and thus can decide to remove it..

In this case you must take care of the files user has kept for future use. Like the wedding photos and childhood photos which we hardly see daily, so they are not modified recently, make sure your code does not delete them without user's permission.

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