Declaring self-referencing pointers in Swift [duplicate]

无人久伴 提交于 2019-12-01 08:05:51

Probably something like this:

var CapturingStillImageContext: COpaquePointer = nil
withUnsafePointer(&CapturingStillImageContext) {
    CapturingStillImageContext = COpaquePointer($0) }

CMutableVoidPointer isn't available anymore as of Beta 3. Theres UnsafePointer and ConstUnsafePointer - you can declare it this way:

let CapturingStillImageContext = UnsafePointer<()>()

I've been using this technique, but it would be nice to find a more elegant solution:

var SelfReferencingKey = initialize_SelfReferencingKey()

func initialize_SelfReferencingKey() -> UnsafePointer<()> {
    return withUnsafePointer(&SelfReferencingKey, { UnsafePointer($0) } )
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!