.h 头文件
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController
@property (retain, nonatomic) IBOutlet UIProgressView *progressView;
/*简单的download代码*/
-(IBAction)goURL;
.m 文件
/*
download index.jsp
*/
-(IBAction)goURL
{
/*手机simulator 应用程序路径*/
NSString *path = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)objectAtIndex:0];
path = [path stringByAppendingPathComponent:@"index.jsp"];
NSLog(@"path=%@",path);
//从该服务器项目中下载index.jsp
NSURL *url = [NSURL URLWithString:@"http://x.x.x:8080/PlaceNaviServer/index.jsp"];
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
//下载到本地文件 Documents中
[request setDownloadDestinationPath:path];
//设置显示进度条
[request setDownloadProgressDelegate:progressView];
[request startSynchronous];
}