是否可以在MonoTouch中访问NSURLCache?

时间:2012-03-27 15:22:57

标签: c# ios xamarin.ios nsurlcache

我想创建自定义Web视图和代理HTTP调用(This blog explains what I'm trying to do)。

我有一个使用NSURLCache在Objective C中工作的实现,但我找不到从MonoTouch中替换NSURLCache的方法。可能吗?或者还有另一种方法来实现这一目标吗?

在Objective C实现中,在AppDelegate中将NSURLCache替换为您自定义的NSURLCache:

- (BOOL)application:(UIApplication *)application
    didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    LocalSubstitutionCache *cache = [[LocalSubstitutionCache alloc] init];
    [NSURLCache setSharedURLCache:cache];

    [window addSubview:viewController.view];
    [window makeKeyAndVisible];

    return YES;
}

1 个答案:

答案 0 :(得分:2)

  

有可能吗?

如果你可以从Objective-C那里做到,那么你应该能够使用MonoTouch从C#中做到这一点。否则这是一个错误,我们会努力解决它: - )

  

但我找不到从MonoTouch中替换NSURLCache的方法

如果替换你的意思是调用它(在Objective-C中)

 +[NSURLCache setSharedURLCache:]

然后MonoTouch等效于:

 NSUrlCache.SharedCache = ...;
相关问题