怪我咯2017-04-17 17:48:42
I thought of a method and it was ok. Add an attribute to NSUserDefaults. In Appdelegate, first check whether there is this attribute to determine whether it is the first time to install the app. If not, it means it is the first time to install the app. Add this attribute. This attribute means The time to clear the cache, the first time is assigned the current system time.
Then every time you open the app, compare this time with the current system time. If the current system time is 7 days greater than this attribute, remove the Cache folder, otherwise do nothing. The original problem was how to determine whether the app was installed for the first time on the mobile phone. Later I learned that you can determine whether there is a custom attribute in NSuserdeafults to determine whether the app is installed for the first time, and the problem was solved
PHP中文网2017-04-17 17:48:42
Record the time of the last cleanup, compare it with the last time after opening >=7 days to clear the cache, and record the current time.