直接给一个路径下载图片,这函数直接使用assi
-(void)downloadWithURL:(NSString*)RequestUrl SavePath:(NSString*)savepath withQueue :(NSOperationQueue *)queue{
NSLog(@"downloadWithURL");
[selfindicatorAddInView];
//初始下载路径
NSURL *url = [NSURL URLWithString:RequestUrl];
//设置下载路径
if( myRequest != nil ){
[myRequestclearDelegatesAndCancel];
myRequest.delegate = nil;
myRequest = nil ;
}
myRequest = [[ASIHTTPRequestalloc] initWithURL:url];
//设置ASIHTTPRequest代理
myRequest.delegate = self;
//设置文件保存路径
[myRequestsetDownloadDestinationPath:savepath];
//获取旧类
//Class oldclass = object_getClass(obj);
//设置基本信息
//[request setUserInfo:[NSDictionary dictionaryWithObjectsAndKeys:obj, @"Object", /*oldclass, @"oldclass", */savepath, @"savePath", info, @"info", nil]];
//设置持续连接
myRequest.shouldAttemptPersistentConnection = YES;
//添加到ASINetworkQueue队列去下载
if( queue == nil ){
if(myQueue == nil){
myQueue = [[ASINetworkQueuealloc]init];
[myQueue go];
}
[myQueueaddOperation:myRequest];
return;
}
[queue addOperation:myRequest];
}