title: Get CIColorCube Filter Working In Swift
body: <p>I am trying to get the CIColorCube filter working. However the Apple documents only provide a poorly explained reference example here:</p>
  
  <pre><code>// Allocate memory
  const unsigned int size = 64;
  float *cubeData = (float *)malloc (size * size * size * sizeof (float) * 4);
  float rgb[3], hsv[3], *c = cubeData;
  
  // Populate cube with a simple gradient going from 0 to 1
  for (int z = 0; z &lt; size; z++){
      rgb[2] = ((double)z)/(size-1); // Blue value
      for (int y = 0; y &lt; size; y++){
          rgb[1] = ((double)y)/(size-1); // Green value
          for (int x = 0; x &lt; size; x ++){
              rgb[0] = ((double)x)/(size-1); // Red value
              // Convert RGB to HSV
              // You can find publicly available rgbToHSV functions on the Internet
              rgbToHSV(rgb, hsv);
              // Use the hue value to determine which to make transparent
              // The minimum and maximum hue angle depends on
              // the color you want to remove
              float alpha = (hsv[0] &gt; minHueAngle &amp;&amp; hsv[0] &lt; maxHueAngle) ? 0.0f: 1.0f;
              // Calculate premultiplied alpha values for the cube
              c[0] = rgb[0] * alpha;
              c[1] = rgb[1] * alpha;
              c[2] = rgb[2] * alpha;
              c[3] = alpha;
              c += 4; // advance our pointer into memory for the next color value
          }
      }
  }
  // Create memory with the cube data
  NSData *data = [NSData dataWithBytesNoCopy:cubeData
                         length:cubeDataSize
                         freeWhenDone:YES];
  CIColorCube *colorCube = [CIFilter filterWithName:@"CIColorCube"];
  [colorCube setValue:@(size) forKey:@"inputCubeDimension"];
  // Set data for cube
  [colorCube setValue:data forKey:@"inputCubeData"];
  </code></pre>
  
  <p>So I have attempted to translate this over to Swift with the following:</p>
  
  <pre><code>var filter = CIFilter(name: "CIColorCube")
      filter.setValue(ciImage, forKey: kCIInputImageKey)
      filter.setDefaults()
  
      var size: UInt = 64
      var floatSize = UInt(sizeof(Float))
      var cubeDataSize:size_t = size * size * size * floatSize * 4
      var colorCubeData:Array&lt;Float&gt; = [
      0,0,0,1,
      0,0,0,1,
      0,0,0,1,
      0,0,0,1,
      0,0,0,1,
      0,0,0,1,
      0,0,0,1,
      0,0,0,1
      ]
  
      var cubeData:NSData = NSData(bytesNoCopy: colorCubeData, length: cubeDataSize)
  </code></pre>
  
  <p>However I get an error when trying to create the cube data:</p>
  
  <pre><code>"Extra argument 'bytesNoCopy' in call"
  </code></pre>
  
  <p>Basically I am creating the cubeData wrong. Can you advise me on how to properly create the cubeData object in Swift?</p>
  
  <p>Thanks!</p>