title: How to convert CFDataRef into NSData?
body: <p>I have <code>CFDataRef</code> and I want to convert it into <code>NSData</code>.</p>
  <pre><code>CGDataProviderRef dataProvider = CGImageGetDataProvider(screenShot);
  CFDataRef data = CGDataProviderCopyData(dataProvider);
  CGDataProviderRelease(dataProvider);
  NSString *imagePathLocation = [destinationPath stringByAppendingString:[@&quot;/&quot; stringByAppendingString:DesktopImage]];
  [[NSFileManager defaultManager]createFileAtPath: imagePathLocation contents:nil attributes:nil];
  fileHandleForImage = [NSFileHandle fileHandleForWritingAtPath:imagePathLocation];
  NSData * data1 = (NSData *)data;
  [fileHandleForImage writeData:data1];
  </code></pre>
  <p>When I typecast (<code>NSData * data1 = (NSData *)data</code>) it image gets corrupted.</p>
  <p>Can anyoone help?</p>