![](https://i-blog.csdnimg.cn/blog_migrate/8f900a89c6347c561fdf2122f13be562.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/961ddebeb323a10fe0623af514929fc1.gif)
- (IBAction)getbigfile:(UIButton *)sender { NSString *str = @"http://b.hiphotos.baidu.com/video/pic/item/e850352ac65c1038698cd94eb7119313b17e894f.jpg"; NSURL *url = [NSURL URLWithString:str]; NSURLRequest * request = [[NSURLRequest alloc]initWithURL:url]; NSURLConnection *conn = [[NSURLConnection alloc]initWithRequest:request delegate:self startImmediately:YES]; [conn start]; }
![](https://i-blog.csdnimg.cn/blog_migrate/8f900a89c6347c561fdf2122f13be562.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/961ddebeb323a10fe0623af514929fc1.gif)
- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response{ self.receivedData = [[NSMutableData alloc]init]; }
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data{ [self.receivedData appendData:data]; NSLog(@"接受到服务器端来的数据%d",data.length); NSString *Data =[[NSString alloc]initWithData:data encoding:NSUTF8StringEncoding]; NSLog(@"%@",Data); }
- (void)connectionDidFinishLoading:(NSURLConnection *)connection{ NSLog(@"222"); NSString *path = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/a.mp4"]; NSLog(@"string = %@",path); [self.receivedData writeToFile:path atomically:YES]; }