title: UIImage imageWithData returns nil
body: <p>I'm developing an iOS 5.0+ app with latest SDK.</p>
  
  <p>On my app I have some C++ image recognition software, and I'm trying to save image recognized by this C++ functions.</p>
  
  <p>I have this array to store image recognized:</p>
  
  <pre><code>int _detectedImages[NSMaxNumDetections ][NSPatchSize * NSPatchSize];
  </code></pre>
  
  <p>I call the C++ function this way:</p>
  
  <pre><code>numberOfDetections = nativeDetect(_resultImages);
  </code></pre>
  
  <p>And with the following code, I try to convert data from <code>_detectedImages</code> to <code>UIImage</code>.</p>
  
  <pre><code>for (int index = 0; index &lt; numberOfDetections; index++)
  {
      if (_resultImages[index] != nil)
      {
          NSData* imageData = [NSData dataWithBytes:&amp;_resultImages[index] length:sizeof(_resultImages[index])];
          NSLog(@"##### Image data size: %d", [imageData length]);
          UIImage* newImage = [UIImage imageWithData:imageData];
          _lastDetectedSignImages[index] = newImage;
      }
  }
  </code></pre>
  
  <p>On the log I get this:</p>
  
  <pre><code>#### Image data size: 2304
  Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSArrayM setObject:atIndex:]: object cannot be nil'
  *** First throw call stack:
  </code></pre>
  
  <p><code>newImage</code> is nil but <code>imageData</code> has data.</p>
  
  <p><strong>Am I doing something wrong when I try to get an <code>UIImage</code> from that data?</strong></p>
  
  <p>The other possibility if that my C++ recognition software is doing something wrong, but I'm not going to show you that code here (sorry, it's copyrighted).</p>
  
  <p>Or I'm not passing <code>_resultImages</code> correctly to <code>nativeDetect</code>.</p>