zumzum zumzum - 2 months ago 102
iOS Question

Unmanaged.passUnretained(self).toOpaque() to Swift 3

I have the following error:

enter image description here

the line of code in the image is this:

context.info = UnsafeMutablePointer(Unmanaged.passUnretained(self).toOpaque())


I am not sure how to fix this. I did look into this:

https://github.com/apple/swift-evolution/blob/master/proposals/0017-convert-unmanaged-to-use-unsafepointer.md

but, I am not sure how to properly fix the error.

Any help?

Answer

This seems to work:

context.info = UnsafeMutablePointer(OpaquePointer(bitPattern: Unmanaged.passUnretained(self)))
Comments