title: How to ignore my app's window on screenshot? (Swift 2.0)
body: <p>I wanted to get an image of the screen, ignoring my app's window.</p>
  
  <p>Found a code example in Objective-C and tried to convert it to Swift.</p>
  
  <p>Objective-C snipped:</p>
  
  <pre><code>// Get onscreen windows
  CGWindowID windowIDToExcude = (CGWindowID)[myNSWindow windowNumber];
  CFArrayRef onScreenWindows = CGWindowListCreate(kCGWindowListOptionOnScreenOnly, kCGNullWindowID);
  CFMutableArrayRef finalList = CFArrayCreateMutableCopy(NULL, 0, onScreenWindows);
  for (long i = CFArrayGetCount(finalList) - 1; i &gt;= 0; i--) {
      CGWindowID window = (CGWindowID)(uintptr_t)CFArrayGetValueAtIndex(finalList, i);
      if (window == windowIDToExcude)
              CFArrayRemoveValueAtIndex(finalList, i);
  }
  // Get the composite image
  CGImageRef ref = CGWindowListCreateImageFromArray(myRectToGrab, finalList, kCGWindowListOptionAll);
  </code></pre>
  
  <p>My version in Swift (where I managed to get so far): </p>
  
  <pre><code>// Get onscreen windows
  let windowIDToExcude = myNSWindow.windowNumber!
  let onScreenWindows = CGWindowListCreate(kCGWindowListOptionOnScreenOnly, kCGNullWindowID)
  let finalList = CFArrayCreateMutableCopy(nil, 0, onScreenWindows)
  
  for var i = CFArrayGetCount(finalList) - 1; i &gt;= 0; i-=1 {
      var window: CGWindowID = (uintptr_t(CFArrayGetValueAtIndex(finalList, i)) as! CGWindowID)
      if window == windowIDToExcude {
          CFArrayRemoveValueAtIndex(finalList, i)
      }
  }
  // Get the composite image
  var ref = CGWindowListCreateImageFromArray(myRectToGrab, finalList, kCGWindowListOptionAll)
  </code></pre>
  
  <p>But it does not work in swift 2.0 and I have no idea why.</p>
  
  <p>Particularly this line can't be compiled:</p>
  
  <blockquote>
    <p>CGWindowListCreate(kCGWindowListOptionOnScreenOnly, kCGNullWindowID)</p>
  </blockquote>
  
  <p>Apparently there is no such thing as <code>CGWindowListCreate</code>, <code>kCGWindowListOptionOnScreenOnly</code> and <code>kCGNullWindowID</code> anymore. </p>