You probably should be writing with the API that allows you to pass an error pointer in
- (BOOL)writeToFile:(NSString *)path options:(NSDataWritingOptions)mask error:(NSError **)errorPtr
Then, you can inspect the NSError
if it does not write properly, and act intelligently with this info.
NSError *error = nil;
BOOL success = [pdfData writeToFile:documentDirectoryFilename options:NSDataWritingAtomic error:&error];
if (!success) {
NSLog(@"Error writing: %@", [error localizedDescription]);
}
The specific error you have is a NSFileNoSuchFileError, a clue that perhaps there are spaces or some other non-supported character in the file path, amongst other reasons.