views:

101

answers:

0

Possible Duplicate:
Load PDF from documents directory - iPhone

I am trying to create a PDF from a file I have stored in the documents directory (1.pdf). Here is my code:

// Get Documents Directory
    NSArray *searchPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); 
    NSString *documentsDirectoryPath = [searchPaths objectAtIndex:0]; 
    NSString *tempPath = [documentsDirectoryPath stringByAppendingPathComponent:[appDelegate.issueToLoad stringByAppendingPathExtension:@"pdf"]];
    NSString *path = [tempPath stringByReplacingOccurrencesOfString:@"localhost/" withString:@""];
    NSLog(@"PATH: %@", path);
    //Display PDF
    pdf = CGPDFDocumentCreateWithURL((CFURLRef)[NSURL fileURLWithPath:path]);
    NSLog(@"PDF: %@", pdf);

The first NSLog produces a link to the file:

/Users/myname/Library/Application Support/iPhone Simulator/3.2/Applications/9C2047A6-DDD2-418F-A329-4EE6E4647770/Documents/1.pdf

However the second NSlog produces :

(NULL)

Is there something wrong with my code?

Thanks