How to create a static pointer variable to itself in Swift?

前端 未结 2 1795
醉酒成梦
醉酒成梦 2021-01-22 05:55

In Objective-C I often use the pattern of using a static void* as an identification tag. At times these tags are only used within that function/method, hence it\'s

2条回答
  •  长发绾君心
    2021-01-22 06:29

    Try this:

    var GetSomeObscureProperty: MyObscureObject = nil
    
    withUnsafePointer(& GetSomeObscureProperty) {
        GetSomeObscureProperty = MyObscureObject($0) 
    }
    

    In short

    let GetSomeObscureProperty = UnsafePointer<()>()
    

提交回复
热议问题