4

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?

zumzum
  • 17,984
  • 26
  • 111
  • 172

2 Answers2

3
UnsafeMutableRawPointer(Unmanaged.passUnretained(self).toOpaque())

works for me

Ivan Vavilov
  • 1,520
  • 1
  • 15
  • 28
0

This seems to work:

context.info = UnsafeMutablePointer(OpaquePointer(bitPattern: Unmanaged.passUnretained(self)))
matt
  • 515,959
  • 87
  • 875
  • 1,141
zumzum
  • 17,984
  • 26
  • 111
  • 172
  • Do you also have a recipe for achieving the inverse, i.e. extracting `mySelf` from `context.info`, in a similar way? – Drux Sep 02 '16 at 03:39