Pooja
Pooja

Reputation: 2200

download .zip or .doc file on iphone

i want to download .zip or .pdf or .doc file on iphone from server via webservice request and webservice is deploy on IIS.

i dont know anything about it

Upvotes: 0

Views: 2224

Answers (2)

kadalamittai
kadalamittai

Reputation: 2166

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);

Upvotes: 3

Carl Veazey
Carl Veazey

Reputation: 18363

Use NSURLConnection or better yet ASIHTTPRequest to download the file as NSData which you write to a file.

Upvotes: 1

Related Questions