download .zip or .doc file on iphone
i want to download .zip or .pdf or .doc file on iph开发者_运维百科one from server via webservice request and webservice is deploy on IIS.
i dont know anything about it
This piece code downloads a pdf and saves it to a temporary location
NSData *pdfData = [NSData dataWithContentsOfURL:pdfURL];
NSString *fileName = [[pdfURL path] lastPathComponent];
NSString *filePath = [NSTemporaryDirectory() stringByAppendingPathComponent:fileName];
NSURL *fileURL = [NSURL fileURLWithPath:filePath];
NSError *writeError = nil;
[pdfData writeToURL: fileURL options:0 error:&writeError];
if( writeError) {
NSLog(@" Error in writing file %@' : \n %@ ", filePath , writeError );
return;
}
NSLog(@"%@",fileURL);
Use NSURLConnection or better yet ASIHTTPRequest to download the file as NSData which you write to a file.
精彩评论