title: UIImagePNGRepresentation writeToFile can errors be catched?
body: <p>i render Thumbnails of newly recieved PDF Document to the Documents-Directory.</p>
  
  <p>I'm using the following code:</p>
  
  <pre><code>CFURLRef pdfURL = CFBundleCopyResourceURL(CFBundleGetMainBundle(), CFSTR("thedoc.pdf"), NULL, NULL);
          CGPDFDocumentRef bookPDF = CGPDFDocumentCreateWithURL((CFURLRef)pdfURL);
          UIGraphicsBeginImageContext(CGSizeMake(100, 130));
          NSUInteger totalNum = CGPDFDocumentGetNumberOfPages(bookPDF);
          CGContextRef context = UIGraphicsGetCurrentContext();
  
          for(int i = 0; i &lt; totalNum; i++ ) {
              CGRect arect = CGRectMake(0,0,200,282);
              CGContextSaveGState(context);
              CGContextTranslateCTM(context, 0.0, 141);
              CGContextScaleCTM(context, 1.0, -1.0);
              CGContextSetGrayFillColor(context, 1.0, 1.0);
              CGContextFillRect(context, arect);
              // Grab the first PDF page
              CGPDFPageRef page = CGPDFDocumentGetPage(bookPDF, i + 1);
              CGAffineTransform pdfTransform = CGPDFPageGetDrawingTransform(page, kCGPDFMediaBox, arect, 0, true);
              // And apply the transform.
              CGContextConcatCTM(context, pdfTransform);
              CGContextDrawPDFPage(context, page);
              // Create the new UIImage from the context
              UIImage* thumbnailImage = UIGraphicsGetImageFromCurrentImageContext();
              if (thumbnailImage == nil) {
                  NSLog(@"ERROR during creation of PNG");
              }
              // SAVE THE IMAGE TO DOCUMENTS-DIRECTORY
              NSString  *pngPath = [NSHomeDirectory() stringByAppendingPathComponent:[NSString stringWithFormat:@"%@/thumbPage%i.png",theLocalFolder ,i]];
              // Write image to PNG
              BOOL writtenBool = [UIImagePNGRepresentation(thumbnailImage) writeToFile:pngPath atomically:YES];
              // END SAVE THE IMAGE TO DOCUMENT-DIRECTORY
              CGContextRestoreGState(context);
              NSLog(@"Rendering PDF-Thumbnail %i (%i): %@", i, writtenBool, [NSString stringWithFormat:@"%@/thumbPage%i.png",theLocalFolder ,i]);
          }
  </code></pre>
  
  <p>There is no error in Console, but the PNGs are not stored to the documents-Directory. The BOOL</p>
  
  <pre><code>writtenBool
  </code></pre>
  
  <p>is "0", what means that the write-action was not succuessful. I don't know why. I write the path in
      pngPath
  also to the console and the path is correct. If i open a terminal and write</p>
  
  <pre><code>open &lt;&lt;copyed path from console&gt;&gt;
  </code></pre>
  
  <p>it opens the correct path in finder.</p>
  
  <p>What could cause this not to work? I had a look at the api but there seems to be no </p>
  
  <pre><code>error:
  </code></pre>
  
  <p>for UIImagePNGRepresentation: writeToFile:</p>
  
  <p>Thanks for your help!</p>