ipad - download .ashx file from server programmatically ios -


i trying download .ashx file server ipad application.

- (void)viewdidload {     [super viewdidload];     // additional setup after loading view, typically nib.    nsstring *file = [nsstring stringwithformat:@"http://url/script.ashx"]; nsurl *fileurl = [nsurl urlwithstring:file];  nsurlrequest *req = [nsurlrequest requestwithurl:fileurl]; nsurlconnection *conn = [nsurlconnection connectionwithrequest:req delegate:self]; }  - (void)connection:(nsurlconnection *)connection didreceiveresponse:(nsurlresponse *)response {     [self.filedata setlength:0];   //  self.totalfilesize = [nsnumber numberwithlonglong:[response expectedcontentlength]]; }  - (void)connection:(nsurlconnection *)connection didreceivedata:(nsdata *)data {     [self.filedata appenddata:data]; }  - (void)connectiondidfinishloading:(nsurlconnection *)connection {     nsarray *dirarray = nssearchpathfordirectoriesindomains(nsdocumentdirectory,    nsuserdomainmask, yes);     nslog(@"%@", [dirarray objectatindex:0]);     nsstring *path = [dirarray objectatindex:0];     nsstring *datapath = [path stringbyappendingpathcomponent:@"script.ashx"];     datapath = [datapath stringbystandardizingpath];       if ([self.filedata writetofile:datapath options:nsatomicwrite error:nil] == no) {         nslog(@"writetofile error");     }     else {         nslog(@"written!");     } } 

any error on above code? please help.


Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -