Answer the question
In order to leave comments, you need to log in
How to get a list of all requests in a UIWebView?
I want to get a list of all requests from UIWebView, i.e. requests for images/css/js files.
I found a method: make a subclass of NSURLCache and in the cachedResponseForRequest method: monitor all requests, but the problem is that with large requests, such as video, I get an out-of-memory crash, clearing the cache by memorywarning does not help.
Are there other ways to intercept requests or how to subordinate this method?
The code:
import <Foundation/Foundation.h>
@interface CacheProxy : NSURLCache
@end
#import "CacheProxy.h"
@implementation CacheProxy
- (NSCachedURLResponse*)cachedResponseForRequest:(NSURLRequest*)request
{
NSLog(@"url %@", request.URL);
return [super cachedResponseForRequest:request];
}
@end
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
CacheProxy *cache = [[CacheProxy alloc] initWithMemoryCapacity:100 * 1024 * 1024
diskCapacity:0
diskPath:nil];
[NSURLCache setSharedURLCache:cache];
}
CFNetwork`__CFURLCache::SetMemoryLimit(long, long):
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question