Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/36.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/99.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 如何从其他视图访问缓存_Iphone_Ios_Uitableview_Caching_Asihttprequest - Fatal编程技术网

Iphone 如何从其他视图访问缓存

Iphone 如何从其他视图访问缓存,iphone,ios,uitableview,caching,asihttprequest,Iphone,Ios,Uitableview,Caching,Asihttprequest,我已经使用ASIHttprequest设置了一个sharedCache,它是从我在子视图中解析的xml创建的。我想知道我是否可以从主视图访问sharedCache,做一些事情来加速我的表 如果您有任何想法、建议、示例想法,我们将不胜感激。ASIDownloadCache已经提供了一个sharedCache。它在应用程序中的任何位置都可见(假设您导入“ASIDownloadCache.h”),因此您应该能够调用[ASIDownloadCache sharedCache],并使用它 编辑:使用多个缓

我已经使用ASIHttprequest设置了一个sharedCache,它是从我在子视图中解析的xml创建的。我想知道我是否可以从主视图访问sharedCache,做一些事情来加速我的表


如果您有任何想法、建议、示例想法,我们将不胜感激。
ASIDownloadCache
已经提供了一个
sharedCache
。它在应用程序中的任何位置都可见(假设您导入“ASIDownloadCache.h”),因此您应该能够调用
[ASIDownloadCache sharedCache]
,并使用它

编辑:使用多个缓存并不太棘手。创建一个单独的类,该类包含在主视图和子视图中。在其中,定义一个方法以返回一个或多个
ASIDownloadCache
对象,并提供一个实现,类似于以下内容:


下载缓存

#import "ASIDownloadCache.h"

@interface DownloadCaches : NSObject

    + (ASIDownloadCache *)imageCache;

@end

下载缓存

#import "DownloadCaches.h"

@implementation DownloadCaches
    static ASIDownloadCache *imageCache = nil;

    + (ASIDownloadCache *)imageCache
    {
        if(imageCache == nil)
        {
            imageCache = [[ASIDownloadCache alloc] init];
            // set imageCache-specific options here
        }

        return imageCache;
    }

@end

您只需调用
[DownloadCaches imageCache]
,如果尚未初始化,它将被初始化,然后返回给您。

好的,很酷。。。我原以为是这样的,但我对设置缓存的方式有点困惑。。我不知道我在哪里保存它。。或者我如何创建多个缓存:P目前我只有一个,但随着我进一步开发我的应用程序,我希望有几个。