i create 1 application has 1 page , in page exist 1 button downloaded file when click on.
i can download file afnetworking in has error ....
this code :
- (ibaction)downloads:(id)sender { nslog(@"start downloads"); nsurlrequest *request = [nsurlrequest requestwithurl: [nsurl urlwithstring: @"http://.../500x333xgalaxy-core-product-image-1tn.jpg, q1367836642.pagespeed.ic.eafbyu8jun.jpg"]]; afurlconnectionoperation *operation = [[afhttprequestoperation alloc] initwithrequest:request]; nsarray *paths = nssearchpathfordirectoriesindomains(nsdocumentdirectory, nsuserdomainmask, yes); nsstring *path = [[paths objectatindex:0] stringbyappendingpathcomponent :@"filename.jpg"]; operation.outputstream = [nsoutputstream outputstreamtofileatpath:path append:no]; [operation setcompletionblockwithsuccess:^(afhttprequestoperation *operation, id responseobject) { nslog(@"successfully downloaded file %@", path); } failure:^(afhttprequestoperation *operation, nserror *error) { nslog(@"error: %@", error); }]; }
this error :
no visible @interface 'afurlconnectionopretion' declares selector 'setcompletionblockwithsuccess'
use following line start operation :
[operation start];
Comments
Post a Comment