A. Glez A. Glez - 11 months ago 214
Swift Question

Swift3 - Ambiguous use of Init

I converted my project to Swift 3. My code was fine and after conversion I have this:

fileprivate func createImage() -> UIImage {
return ImageProcessor.imageFromARGB32Bitmap(Data(bytes: UnsafePointer<UInt8>(&pixelBuffer), count: pixelBuffer.count), width: framebufferwidth, height: framebufferheight)

The error:

Ambiguous use of Init

How to fix it?

Answer Source

Try this:

    return ImageProcessor.imageFromARGB32Bitmap(Data(bytes: pixelBuffer), width: framebufferwidth, height: framebufferheight)

(Assuming ImageProcessor.imageFromARGB32Bitmap takes Data as its first parameter.)

You have no need to get an UnsafePointer from an Array of UInt8.