???????????????е????
????????????????2????
1 #import "YYViewController.h"
2 #import "ASIHTTPRequest.h"
3
4 @interface YYViewController ()
5
6
7 @end
8
9 @implementation YYViewController
10
11 - (void)viewDidLoad
12 {
13     [super viewDidLoad];
14 }
15
16 -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
17 {
18     //???????????????
19     [self download1];
20 }
21
22 #pragma mark-???????
23 //???1
24 -(void)download
25 {    //1.???????????
26     NSURL *url=[NSURL URLWithString:@"http://127.0.0.1:8080/MJServer/resources/video.zip"];
27     ASIHTTPRequest *request=[ASIHTTPRequest requestWithURL:url];
28
29     //2.???????????????????е??????
30     [request setDataReceivedBlock:^(NSData *data) {
31         NSLog(@"%d"??data.length);
32     }];
33
34     //3.??????????????
35     [request startAsynchronous];
36 }
37
38 //???2
39 -(void)download1
40 {
41     //1.???????????
42     NSURL *url=[NSURL URLWithString:@"http://127.0.0.1:8080/MJServer/resources/video.zip"];
43     ASIHTTPRequest *request=[ASIHTTPRequest requestWithURL:url];
44
45     //2.????????????????·??
46     NSString *cachepath=[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory?? NSUserDomainMask?? YES)lastObject];
47     NSString *filename=[cachepath stringByAppendingPathComponent:@"video.zip"];
48     request.downloadDestinationPath=filename;
49     NSLog(@"%@"??filename);
50
51     //3.????????????????
52     [request startAsynchronous];
53
54     //4.????????????
55     [request setCompletionBlock:^{
56         NSLog(@"??????");
57     }];
58 }
59
60 @end
????????????
?????????????
??????????????????????asi??????????????????????????????????????????輴?????????????????
??????1?????????????
??????2??????????????????·????
??????3?????????????????????????????
??????????????????????У???????????????????????????????д??????????·??????????????????????????????????????????
????asi???????????cfnoteworking????????á?????????????block????????????????????
??????????????asi??????????????μ????????????
???????????????????????????????
?????????????
1 #import "YYViewController.h"
2 #import "ASIHTTPRequest.h"
3
4 @interface YYViewController ()<ASIProgressDelegate>
5 @property (weak?? nonatomic) IBOutlet UIProgressView *progress;
6 @end
7
8 @implementation YYViewController
9
10 - (void)viewDidLoad
11 {
12     [super viewDidLoad];
13 }
14
15 -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
16 {
17     //???????????????
18     [self download];
19 }
20
21 #pragma mark-???????
22 -(void)download
23 {
24     //1.???????????
25     NSURL *url=[NSURL URLWithString:@"http://127.0.0.1:8080/MJServer/resources/video.zip"];
26     ASIHTTPRequest *request=[ASIHTTPRequest requestWithURL:url];
27
28     //2.????????????????·??
29     NSString *cachepath=[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory?? NSUserDomainMask?? YES)lastObject];
30     NSString *filename=[cachepath stringByAppendingPathComponent:@"video.zip"];
31     request.downloadDestinationPath=filename;
32     NSLog(@"%@"??filename);
33
34     //3.???????????????
35     request.downloadProgressDelegate=self.progress;
36
37     //4.????????????????
38     [request startAsynchronous];
39
40     //5.??????????
41     [request setCompletionBlock:^{
42         NSLog(@"?????????????");
43     }];
44 }
45
46 #pragma mark-??????????????????
????asi???????????????????????????????????????
????????????????????????£?
????request.allowResumeForFileDownloads=YES;
???????????????????????????????????30???????????У???????????????????????ε??????????????????????????????70?????????д??????С?
???????????????????????
????[request clearDelegatesAndCancel];