I want to have my iPhone application create a PDF file and store it in an appropriate place - probably the iBooks folder so it can be easily retrieved using iTunes, but that's a change for later once I have the saving part working. I've followed the PDF saving tutorial on the Apple site to the letter, including swapping out CGContextBeginPage and CGContextEndPage for their PDF specific equivalents, and I've checked that the save filename is set to the correct spot, but either no file is being created or I just can't find where it's being stored. Here's the code, any ideas what's wrong? Is it the code, or does this kind of operation just not run in the simulator?
CGRect b = CGRectMake(0, 0, 612, 792);
NSMutableString *exportPath = [[NSMutableString alloc]
initWithString:[[NSBundle mainBundle] bundlePath]];
[exportPath appendString:@"/myfile.pdf"];
CGContextRef pdfContext;
CFStringRef path = CFStringCreateWithCString (NULL, [exportPath UTF8String], kCFStringEncodingUTF8);
CFURLRef url; CFMutableDictionaryRef myDictionary = NULL;
url = CFURLCreateWithFileSystemPath(NULL, path, kCFURLPOSIXPathStyle, 0);
CFRelease(path);
myDictionary = CFDictionaryCreateMutable(NULL, 0,
&kCFTypeDictionaryKeyCallBacks,
&kCFTypeDictionaryValueCallBacks);
CFDictionarySetValue(myDictionary, kCGPDFContextTitle, CFSTR("My PDF File"));
CFDictionarySetValue(myDictionary, kCGPDFContextCreator, CFSTR("My Name"));
pdfContext = CGPDFContextCreateWithURL (url, &b, myDictionary);
CFRelease(myDictionary);
CFRelease(url);
CGPDFContextBeginPage(pdfContext, NULL);
[self drawToContext: pdfContext Bounds:b];
CGPDFContextEndPage(pdfContext);
CGPDFContextClose(pdfContext);
CGContextRelease (pdfContext);