简体   繁体   English

在iOS 7中调用新ViewController时如何清除缓存?

[英]How To Clear Cache Memory When New ViewController Call In IOS 7?

I use NSURLConnection to send request on server NSURLConnection increase cache memory and application crash due to low memory. 我使用NSURLConnection在服务器上发送请求NSURLConnection增加了缓存内存,并且由于内存不足而导致应用程序崩溃。 I use this code for clearing Cache: 我使用以下代码清除缓存:

[[NSURLCache sharedURLCache] removeAllCachedResponses];

But in iOS 7 this code doesn't work any more. 但是在iOS 7中,此代码不再起作用。 Does anyone have any idea how to clear cache memory ? 有谁知道如何清除缓存?

You can create an NSURLCache with a specific memory or disk usage limitation with -setDiskCapacity: or -setMemoryCapacity: . 您可以创建一个NSURLCache特定内存或磁盘使用限制与-setDiskCapacity:-setMemoryCapacity: You can clear the cache in UIViewController 's -viewWillDisappear: or -viewDidDisappear: . 您可以在UIViewController-viewWillDisappear:-viewDidDisappear:清除缓存。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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