赞
踩
很久以前,就把这篇文章的andriod部分和服务器部分搞定,最近论文送审途中,于是写了几行简单的代码如下。
把AFNetwork拿来做一下。具体代码如下:
- -(void)download
- {
- NSURLSessionConfiguration *config = [NSURLSessionConfiguration defaultSessionConfiguration];
- AFURLSessionManager *manager = [[AFURLSessionManager alloc] initWithSessionConfiguration:config];
-
- NSString *urlString = @"http:192.168.0.179:8080/Myweb/download.do";
-
-
-
- urlString = [urlString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
-
- NSURL *url = [NSURL URLWithString:urlString];
- NSURLRequest *request = [NSURLRequest requestWithURL:url];
-
-
- NSURLSessionDownloadTask *task = [manager downloadTaskWithRequest:request progress:nil destination:^NSURL *(NSURL *targetPath, NSURLResponse *response) {
- // 指定下载文件保存的路径
- // NSLog(@"%@ %@", targetPath, response.suggestedFilename);
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。