A. Glez A. Glez - 2 months ago 44
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

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.

Comments