Я создаю PDF-файл и пытаюсь просмотреть его, как показано ниже, но URL-адрес обычно возвращает NIL, несмотря на мое форматирование (что, как представляется, разрешает проблему остальных с этой общей проблемой). Я должен упустить что-то еще. Есть идеи?NSURL всегда nil dispite encoding
NSArray *path = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *docDirectory = [path objectAtIndex:0];
docDirectory = [docDirectory stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSURL *URL = [[NSBundle mainBundle] URLForResource:docDirectory withExtension:@"pdf"];
if (URL) {
// Initialize Document Interaction Controller
self->documentInteractionController = [UIDocumentInteractionController interactionControllerWithURL:URL];
// Configure Document Interaction Controller
[self->documentInteractionController setDelegate:self];
// Preview PDF
[self->documentInteractionController presentPreviewAnimated:YES];
}