iphone pdf download

后端 未结 1 2000
猫巷女王i
猫巷女王i 2020-12-18 17:11
        -(IBAction)click;
    {

            NSURL *url = [NSURL URLWithString:URL_TO_DOWNLOAD]; 
            NSString *tempDownloadPath = [[self documentsDirectory]         


        
相关标签:
1条回答
  • 2020-12-18 17:41

    To check if the file exists, use:

    BOOL exists = [[NSFileManager defaultManager] fileExistsAtPath:file]
    

    To display the PDF once the request has finished, you can either open it in a UIWebView or use the CGPDF* set of functions to render it.

    ASIHTTPRequest's setDownloadDestinationPath expects to receive an absolute file path, and it seems you're just passing the documents directory instead. You could get the filename from your URL and append it to the documents directory path:

    NSString *filename = [[url absoluteString] lastPathComponent];
    
    NSString *directory = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,YES) objectAtIndex:0];
    NSString *destPath = [directory stringByAppendingPathComponent:filename];
    
    [request setDownloadDestinationPath:destPath];
    

    Then to check if the downloaded file actually exists, you can use destPath again.

    0 讨论(0)
提交回复
热议问题