Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想将实现转换为 NSValue,但这是错误的。
在 Objective-C 中,可以使用这一行来转换:
[NSValue valueWithPointer:implementation]
但在 Swift 中,如何转换?
正如它所说,它需要一个UnsafePointer,而不是一个COpaquePointer。所以转换它:
UnsafePointer
COpaquePointer
let impValue = NSValue(pointer: UnsafePointer(imp))