1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
| urlStr = @"https://central.github.com/deployments/desktop/desktop/latest/darwin"; urlStr1 = @"http://mac.yxdownload.com/bmc/VMwareFusionpro1012.dmg";
/*开始下载 继续下载*/ - (IBAction)start:(id)sender { __weak __typeof(self)weakSelf = self; [WhdeBreakPoint asynDownloadWithUrl:urlStr progressBlock:^(float progress, long long receiveByte, long long allByte, long long rate) { weakSelf.progressView.progress = progress; weakSelf.progressLabel.text = [NSString stringWithFormat:@"%d%% %@/%@ %@ ", (int)(progress*100), [WhdeNetworkService format:receiveByte], [WhdeNetworkService format:allByte], [WhdeNetworkService format:rate]]; } successBlock:^(NSString *filePath) { NSLog(@"%@", filePath); } failureBlock:^(NSString *filePath, NSError *error) { NSLog(@"%@\n%@", filePath, error); }]; [WhdeBreakPoint asynDownloadWithUrl:urlStr1 progressBlock:^(float progress, long long receiveByte, long long allByte, long long rate) { weakSelf.progressView1.progress = progress; weakSelf.progressLabel1.text = [NSString stringWithFormat:@"%d%% %@/%@ %@ ", (int)(progress*100), [WhdeNetworkService format:receiveByte], [WhdeNetworkService format:allByte], [WhdeNetworkService format:rate]]; } successBlock:^(NSString *filePath) { NSLog(@"%@", filePath); } failureBlock:^(NSString *filePath, NSError *error) { NSLog(@"%@\n%@", filePath, error); }]; }
- (IBAction)pause:(id)sender { [WhdeBreakPoint pause:urlStr]; [WhdeBreakPoint pause:urlStr1]; }
- (IBAction)delete:(id)sender { [WhdeFileManager deleteFile:[NSURL URLWithString:urlStr]]; [WhdeFileManager deleteFile:[NSURL URLWithString:urlStr1]]; self.progressView.progress = 0; self.progressView1.progress = 0; self.progressLabel.text = @"0%"; self.progressLabel1.text = @"0%"; }
|