知了此生 2015-08-18 13:16 采纳率: 0%
浏览 1452

使用ASIHTTPRequest第三方类库,来实现上传下载

使用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];
}
  • 写回答

1条回答 默认 最新

  • Tadas-Gao 2015-08-25 15:08
    关注

    ASIHTTPRequest类库使用简介
    ----------------------同志你好,我是CSDN问答机器人小N,奉组织之命为你提供参考答案,编程尚未成功,同志仍需努力!

    评论

报告相同问题?

悬赏问题

  • ¥100 三相直流充电模块对数字电源芯片在物理上它必须具备哪些功能和性能?
  • ¥30 数字电源对DSP芯片的具体要求
  • ¥20 antv g6 折线边如何变为钝角
  • ¥30 如何在Matlab或Python中 设置饼图的高度
  • ¥15 nginx中的CORS策略应该如何配置
  • ¥30 信号与系统实验:采样定理分析
  • ¥100 我想找人帮我写Python 的股票分析代码,有意请加mathtao
  • ¥20 Vite 打包的 Vue3 组件库,图标无法显示
  • ¥15 php 同步电商平台多个店铺增量订单和订单状态
  • ¥17 pro*C预编译“闪回查询”报错SCN不能识别