这个Obj-C代码的快速等价是什么?
我猜错了CMutableVoidPointer
static void *CapturingStillImageContext = &CapturingStillImageContext;
答案 0 :(得分:3)
CMutableVoidPointer
不再可用.Theres UnsafePointer
和ConstUnsafePointer
- 您可以这样声明:
let CapturingStillImageContext = UnsafePointer<()>()
答案 1 :(得分:1)
可能是这样的:
var CapturingStillImageContext: COpaquePointer = nil
withUnsafePointer(&CapturingStillImageContext) {
CapturingStillImageContext = COpaquePointer($0) }
答案 2 :(得分:0)
我一直在使用这种技术,但找到更优雅的解决方案会很好:
var SelfReferencingKey = initialize_SelfReferencingKey()
func initialize_SelfReferencingKey() -> UnsafePointer<()> {
return withUnsafePointer(&SelfReferencingKey, { UnsafePointer($0) } )
}