How to convert IMP to NSValue with Swift?

274 Views Asked by At

enter image description here

I want convert the implementation to NSValue, but it's err.

In Objective-C, can use this line to convert:

[NSValue valueWithPointer:implementation]

but in Swift, how to convert?

1

There are 1 best solutions below

0
Rob Napier On BEST ANSWER

As it says, it needs an UnsafePointer, not a COpaquePointer. So convert it:

let impValue = NSValue(pointer: UnsafePointer(imp))