使用ASIHTTPRequest第三方类库,来实现上传下载,两个按钮"下载开始"和"暂停"分别绑定方法,使用alloc,init方式创建Request,在"暂停"方法中清除协议方法和取消,未关ARC,已经配置好各项内容,点击"下载开始"按钮可以执行,但一点"暂停"程序就崩,一直说指向了被释放的对象,不知是什么原因,难道不可以Arc和非ARC混用?
求教各位大神.
@interface YLMViewController ()
//{
// ASIHTTPRequest *_request;
//}
@property (weak, nonatomic) IBOutlet UIProgressView *downloadProgressView;
@property (weak, nonatomic) IBOutlet UIProgressView *uploadProgressView;
@property (nonatomic,retain)ASIHTTPRequest *request;
@end
@implementation YLMViewController
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (NSString *)filePath{
return [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/Download.zip"];
}
- (NSString *)temFilePath{
return [NSHomeDirectory() stringByAppendingPathComponent:@"tmp/tmp"];
}
- (IBAction)downloadClick:(UIButton *)sender {
NSURL *url=[NSURL URLWithString:@"http://localhost:8080/MyXMLServer/netBeans.zip"];
_request =[[ASIHTTPRequest alloc]initWithURL:url];
// _request=request;
_request.timeOutSeconds = 30;
_request.downloadProgressDelegate=self;
[_request setDownloadDestinationPath:[self filePath]];
[_request setTemporaryFileDownloadPath:[self temFilePath]];
[_request setAllowResumeForFileDownloads:YES];
[_request start];
NSLog(@"request--------%p",_request);
}
- (IBAction)downloadPause:(UIButton *)sender
{
NSLog(@"request2--------%@",_request);
NSLog(@"===========");
[self.request clearDelegatesAndCancel];
}
ASIHTTPRequest类库使用简介
----------------------同志你好,我是CSDN问答机器人小N,奉组织之命为你提供参考答案,编程尚未成功,同志仍需努力!