4

I'm working on an iOS application that displays locally-stored content (HTML files) in a UIWebView.

The problem is that some of the assets referenced from the HTMLs (for example fonts and images) take quite a while when loaded for the first time. I assume that the solution to the problem is to somehow cache these assets with NSURLCache before they're used in a UIWebView, but this seems to cause some trouble.

What I have tried so far:

  • Subclassing NSURLCache and overriding cachedResponseForRequest so that it returns a response with the asset preloaded in an NSData object. Preloading is done in the init method. The overridden cachedResponseForRequest seems to get called but for some reason the UIWebView still loads the asset from the file system.

  • Using storeCachedResponse:forRequest: to cache NSCachedURLResponse objects containing the assets before they're used in a UIWebView.

Neither of these seems to help. Any advice for where to look for the problem?

1

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.