iphone file download not working
Posted
by Anonymous
on Stack Overflow
See other posts from Stack Overflow
or by Anonymous
Published on 2010-03-20T19:48:55Z
Indexed on
2010/03/20
19:51 UTC
Read the original article
Hit count: 254
Hi, In my app I 'm first connecting to a web service, which in return sends a url for a file. I use the url to download the file and then display it on the new view.
I get the correct URL but not able to download file from that location. I have another test app which will download file from the same location and it works like a charm.
following is my code for webservice-file download. This is a snippet of the code where i 'm parsing the web service xml and then pass the result to NSData for file download.
Any suggestions where am i going wrong --
I 'm referring to the following tutorials.
if ([elementName isEqualToString:@"PRHPdfResultsResult"])
{
NSLog(soapResults);
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle:@"Report downloaded from:"
message:soapResults
delegate:self
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
NSData *pdfData = [[NSData alloc] initWithContentsOfURL:[NSURL URLWithString:soapResults]];
//Store the Data locally as PDF File
NSString *resourceDocPath = [[NSString alloc] initWithString:[[[[NSBundle mainBundle] resourcePath] stringByDeletingLastPathComponent] stringByAppendingPathComponent:@"Documents"]];
NSString *filePath = [resourceDocPath stringByAppendingPathComponent:@"myPDF.pdf"];
[pdfData writeToFile:filePath atomically:YES];
[alert show];
[alert release];
[soapResults setString:@""];
elementFound = FALSE;
}
© Stack Overflow or respective owner