title: How to convert Swift array into CFArray?
body: <p>I'm trying to capture a window list in a Mac OS X app using Swift. The CGWindowListCreateImageFromArray function requires a CFArray. I've tried several things and this is the closest I've got. Or is there a better way to convert the array?</p>
  
  <pre><code>import Cocoa
  
  // Example swift array of CGWindowID's
  var windowIDs = [CGWindowID]();
  windowIDs.append(1);
  windowIDs.append(2);
  
  // Convert to CFArray using CFArrayCreate
  let allocator = kCFAllocatorDefault
  let numValues = windowIDs.count as CFIndex
  let callbacks: UnsafePointer&lt;CFArrayCallBacks&gt; = nil
  var values: UnsafeMutablePointer&lt;UnsafePointer&lt;Void&gt;&gt; = nil
  
  /* how do I convert windowIDs to UnsafeMutablePointer&lt;UnsafePointer&lt;Void&gt;&gt; for the values? */
  
  let windowIDsCFArray = CFArrayCreate(allocator, values,  numValues, callbacks);
  
  let capture = CGWindowListCreateImageFromArray(CGRectInfinite, windowIDsCFArray, CGWindowImageOption(kCGWindowListOptionOnScreenOnly));
  </code></pre>