欢迎使用CSDN-markdown编辑器
来源:互联网 发布:2016淘宝客退款佣金 编辑:程序博客网 时间:2024/06/06 00:36
import “ViewController.h”
import “DACircularProgressView.h”
@interface ViewController ()
@property (nonatomic, assign) long long totalLength;
@property (nonatomic, assign) long long currentLength;
@property (weak, nonatomic) DACircularProgressView *proView;
@property (strong, nonatomic) NSFileHandle *fileHand;
@end
@implementation ViewController
(void)viewDidLoad {
[super viewDidLoad];
}(void)touchesBegan:(NSSet )touches withEvent:(UIEvent )event {
NSURLSession *session = [NSURLSession sessionWithConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration] delegate:self delegateQueue:[NSOperationQueue mainQueue]];NSURLSessionDownloadTask *downTask = [session downloadTaskWithURL:[NSURL URLWithString:@”http://localhost/05.zip“]];
[downTask resume];
}(void)URLSession:(NSURLSession )session downloadTask:(NSURLSessionDownloadTask )downloadTask
didFinishDownloadingToURL:(NSURL *)location {NSLog(@”完成下载”);
NSString *path = [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES)lastObject];
NSString *path1 = [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, NO)lastObject];
NSLog(@”path1=%@ path2=%@”, path, path1);NSFileManager *fileM = [NSFileManager defaultManager];
// NSURL *url = [NSURL URLWithString:[path stringByAppendingPathComponent:downloadTask.response.suggestedFilename]];
// [fileM moveItemAtURL:[NSURL URLWithString:location.path] toURL:[NSURL URLWithString:[path stringByAppendingPathComponent:downloadTask.response.suggestedFilename]] error:nil];
[fileM moveItemAtPath:location.path toPath:[path stringByAppendingPathComponent:downloadTask.response.suggestedFilename] error:nil];
}
/* Sent periodically to notify the delegate of download progress. */
- (void)URLSession:(NSURLSession )session downloadTask:(NSURLSessionDownloadTask )downloadTask
didWriteData:(int64_t)bytesWritten
totalBytesWritten:(int64_t)totalBytesWritten
totalBytesExpectedToWrite:(int64_t)totalBytesExpectedToWrite {
NSLog(@”正在下载%f”, (double)totalBytesWritten / totalBytesExpectedToWrite);
}
/* Sent when a download has been resumed. If a download failed with an
* error, the -userInfo dictionary of the error will contain an
* NSURLSessionDownloadTaskResumeData key, whose value is the resume
* data.
*/
- (void)URLSession:(NSURLSession )session downloadTask:(NSURLSessionDownloadTask )downloadTask
didResumeAtOffset:(int64_t)fileOffset
expectedTotalBytes:(int64_t)expectedTotalBytes {
NSLog(@”回复”);
}
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 常用正则表达式(笔记)
- LPC1788---串口设置
- android开发之播放音乐的方法
- java:IO流学习小结
- zookeeper入门
- 欢迎使用CSDN-markdown编辑器
- 用warshall算法求关系闭包(离散数学)
- PHP 5.3、5.4、5.5、5.6 中的新特性
- MYSQL计算时间间隔——————TimeStampDiff()
- LPC1788--I2C设置驱动PCF8574 与特别注意事项
- [leetcode] Excel Sheet Column Title
- 算法之递归练习
- Docker 使用方法总结之:管理工具 shipyard 的详细使用指南
- near指针,far指针,huge指针