2 Replies
      Latest reply: Oct 13, 2016 6:44 AM by Axoft RSS
      Axoft Level 1 Level 1 (0 points)

        Hi,

        I tried to use removeCachedResponseForRequest but it doesn't remove anything. Apparently is broken since IOS 8.

         

        NSURLCache.sharedURLCache().removeCachedResponseForRequest(request)
        
        

         

        I checked and the "request" is in the array of requests inside NSURLCache.sharedURLCache()

         

        Any idea or work around to fix it?

        Thank you for your help.

        • Re: removeCachedResponseForRequest doesn't work in IOS 9?
          eskimo Apple Staff Apple Staff (6,075 points)

          I checked and the "request" is in the array of requests inside NSURLCache.sharedURLCache()

          I don’t understand this comment.  NSURLCache does not publish an “array of requests”, at least not via any public API.

          However, the bug you’re seeing is real.  It was reported as fixed in iOS 10 (r. 22788696) but that fix isn’t working for me.  I’ve filed a new bug about this (r. 28752537).


          There’s a couple of ways you can work around this:

          • You can dump the entire cache using removeAllCachedResponses().

          • You can set the cache policy on any new request for this resource to .reloadIgnoringLocalCacheData, causing that request to ignore the cached value.

          Share and Enjoy

          Quinn “The Eskimo!”
          Apple Developer Relations, Developer Technical Support, Core OS/Hardware
          let myEmail = "eskimo" + "1" + "@apple.com"

            • Re: removeCachedResponseForRequest doesn't work in IOS 9?
              Axoft Level 1 Level 1 (0 points)
              I don’t understand this comment.  NSURLCache does not publish an “array of requests”, at least not via any public API.

               

              I explain wrong. I use NSURLCache.sharedURLCache().cachedResponseForRequest(request) to know if the response exists in the NSURLCache.sharedURLCache().

               

              Mmmm i wil try the second way.

               

              Thank eskimo