新手提问,IOS7  , ARC用ASI做缓存报错,百度半天没解决方法,发帖求助代码如下================
//设置缓存
    NSString *cachePath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];
    NSLog(@"===%@",cachePath);
    ASIDownloadCache *cache = [[ASIDownloadCache alloc] init];
    [cache setStoragePath:cachePath];
    cache.defaultCachePolicy = ASIOnlyLoadIfNotCachedCachePolicy;
    asiRequest.cacheStoragePolicy = ASICacheForSessionDurationCacheStoragePolicy;
    asiRequest.downloadCache =cache;
================
运行后错误如下2014-08-13 14:03:20.198 flsd[32013:60b] ===/Users/erp/Library/Application Support/iPhone Simulator/7.1/Applications/E4F3A187-108A-43BD-842F-B562F41BC460/Documents
2014-08-13 14:03:20.208 flsd[32013:3703] -[__NSArrayM defaultCachePolicy]: unrecognized selector sent to instance 0x8c898e0
2014-08-13 14:03:20.222 flsd[32013:60b] 请求网路出错:Error Domain=ASIHTTPRequestErrorDomain Code=10 "NSInvalidArgumentException" UserInfo=0x8c8fdb0 {NSLocalizedFailureReason=-[__NSArrayM defaultCachePolicy]: unrecognized selector sent to instance 0x8c898e0, NSUnderlyingError=0x8d75000 "The operation couldn’t be completed. (ASIHTTPRequestErrorDomain error 10.)", NSLocalizedDescription=NSInvalidArgumentException}
急盼!

解决方案 »

  1.   

    你这个cache对象变成了一个数组,你看看是不是其他地方的代码原因,或者是这个cache可能被释放了
      

  2.   

    上面代码全屏幕,用 [asiRequest setDownloadCache:[ASIDownloadCache sharedCache]];结果可以正常缓存。这个cache 是不是new错了呢?
      

  3.   

    这是ASI指定的方法:[ASIDownloadCache sharedCache]
    你直接alloc init的话,它肯定无法保证会正常运行