Is it possible to access NSURLCache in MonoTouch?
-
27-05-2021 - |
Question
I want to create a custom web view and proxy HTTP calls (This blog explains what I'm trying to do).
I have an implementation working in Objective C using NSURLCache but I can't find a way to replace the NSURLCache from within MonoTouch. Is it possible? Or is there another way to achieve this?
In the Objective C implementation the replace the NSURLCache with your custom one in the AppDelegate here:
- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
LocalSubstitutionCache *cache = [[LocalSubstitutionCache alloc] init];
[NSURLCache setSharedURLCache:cache];
[window addSubview:viewController.view];
[window makeKeyAndVisible];
return YES;
}
Solution
Is it possible?
If you can do it from Objective-C then you should be able to do the same from C# using MonoTouch. Otherwise it's a bug and we'll work to fix it asap :-)
but I can't find a way to replace the NSURLCache from within MonoTouch
If by replace you mean calling this (in Objective-C)
+[NSURLCache setSharedURLCache:]
then the MonoTouch equivalent is:
NSUrlCache.SharedCache = ...;