新手提问,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}
急盼!
//设置缓存
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}
急盼!
你直接alloc init的话,它肯定无法保证会正常运行