我的pdf文件保存在iPhone中的位置

时间:2016-09-12 08:10:26

标签: ios iphone

我在iPhone上使用此代码下载pdf按钮点击如下: -

- (IBAction)download:(id)sender {

    self.downloadedMutableData = [[NSMutableData alloc] init];
    urlRequest = [NSURLRequest requestWithURL:[NSURL URLWithString:@"https://www.tutorialspoint.com//objective_c/objective_c_tutorial.pdf"]
                                                cachePolicy:NSURLRequestReloadIgnoringLocalCacheData
                                            timeoutInterval:60.0];
    self.connectionManager = [[NSURLConnection alloc] initWithRequest:urlRequest delegate:self];
}


#pragma mark - Delegate Methods
-(void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response {
    NSLog(@"%lld", response.expectedContentLength);
    self.urlResponse = response;
}

-(void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {
    [self.downloadedMutableData appendData:data];
    progress.progress = ((100.0/self.urlResponse.expectedContentLength)*self.downloadedMutableData.length)/100;
    if (progress.progress == 1) {
        progress.hidden = YES;
    } else {
        progress.hidden = NO;
    }
    float percentage=((100.0/self.urlResponse.expectedContentLength)*self.downloadedMutableData.length);
    percentageLbl.text = [NSString stringWithFormat:@"%.0f%%",percentage];
    NSLog(@"%.0f%%",percentage);
}


-(void)connectionDidFinishLoading:(NSURLConnection *)connection {

    NSLog(@"Finished");
    if (self.downloadedMutableData)
            {
                NSString  *filePath = [NSString stringWithFormat:@"%@/%@", [[NSBundle mainBundle] resourcePath], @"Pdf.pdf"];
                [self.downloadedMutableData writeToFile:filePath atomically:YES];
            }
}

我不知道我的pdf文件在iPhone中的保存位置。我想在iPhone中的图库中保存pdf文件 你能救我吗?

0 个答案:

没有答案