search

Home  >  Q&A  >  body text

iOS 缓存清理问题

app如何实现每隔一周自动清理一次缓存

高洛峰高洛峰2886 days ago388

reply all(3)I'll reply

  • 怪我咯

    怪我咯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

    reply
    0
  • PHP中文网

    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.

    reply
    0
  • 怪我咯

    怪我咯2017-04-17 17:48:42

    Egocache

    reply
    0
  • Cancelreply