A. Glez A. Glez - 1 year ago 287
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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download