내 앱에서 pdf를 다운로드 한 다음 버튼을 누르면 새로운보기로 표시됩니다. 나는이 코드에서 어딘가에 문제를 고정 몇 가지 문제 해결 후새보기에서 다운로드 한 PDF를 열려고하면 오류가 발생합니다.
-[NSURL initFileURLWithPath:]: nil string parameter'
:
가 나는 오류가 발생합니다. 가리키는 경로는 다운로드 한 PDF가있는 /Documents
폴더에 있습니다. 따라서 문서는 기본 번들에 없습니다.
NSString *path = [[NSBundle mainBundle] pathForResource:PDFpathwithextension ofType:@"pdf"];
NSURL *url = [NSURL fileURLWithPath:path];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
여기 다운로드 코드입니다 : NSURL
으로
//Start an NSURL connection to download from the remotepath
NSData *pdfData = [[NSData alloc] initWithContentsOfURL:remotepathURL];
//Store the Data locally as PDF File
NSString *resourceDocPath = [[NSString alloc] initWithString:[[[[NSBundle mainBundle] resourcePath] stringByDeletingLastPathComponent] stringByAppendingPathComponent:@"Documents"]];
NSString *filePath = [resourceDocPath stringByAppendingPathComponent:[newdata.ThirdPickerName stringByAppendingFormat:@".pdf"]];
pdfData writeToFile:filePath atomically:YES];
기술적으로 여기에 예외가 표시되어 충돌로 이어집니다. –