After doing some testing I looked up the implementation and Unmanaged it is
very misleading in how it is behaves and is implemented.
When you call toOpaque() it returns the result of unsafeBitCast(_value, to:
UnsafeRawPointer.self). _value is an internal field we can't directly
access, in your
> On Sep 23, 2017, at 3:44 AM, nyg nyg via swift-users
> wrote:
>
> Hello all,
>
> I'm trying to get an UnsafeMutablePointer from an
> UnsafeMutableRawPointer obtained using the Unmanaged structure:
>
> class C { var foo = 42, bar = "bar" }
> let c = C()
>
> let
Hello all,
I'm trying to get an UnsafeMutablePointer from an
UnsafeMutableRawPointer obtained using the Unmanaged structure:
class C { var foo = 42, bar = "bar" }
let c = C()
let rawPointer = Unmanaged.passUnretained(c).toOpaque()
let pointer = rawPointer.bindMemory(to: C.self, capacity: 1)