iOS开发网络编程之断点续传

2020-01-15 17:02:30刘景俊

如何调用


@interface ViewController ()
@end

@implementation ViewController
/**
 * 开始下载
 */
- (IBAction)start:(id)sender {
  // 启动任务
  NSString * downLoadUrl = @"http://www.easck.com/group11/M01/93/AF/wKgDa1dzzJLBL0gCAPUzeJqK84Y539.m4a";

  [[DownLoadManager sharedInstance]downLoadWithURL:downLoadUrl progress:^(float progress) {
    NSLog(@"###%f",progress);

  } success:^(NSString *fileStorePath) {
    NSLog(@"###%@",fileStorePath);

  } faile:^(NSError *error) {
    NSLog(@"###%@",error.userInfo[NSLocalizedDescriptionKey]);
  }];
}
/**
 * 暂停下载
 */
- (IBAction)pause:(id)sender {
  [[DownLoadManager sharedInstance]stopTask];
}

@end

总结

这里只能实现单个任务下载,大家可以自己想想办法,看如何实现多任务下载,并且实现断点续传功能。并且为了更加便于操作,建议把存储信息换成使用数据库存储。以上就是这篇文章的全部内容了,希望对大家学习IOS开发有所帮助。


注:相关教程知识阅读请移步到IOS开发频道。