To get Pointer for property

Updated
Dec 15, 2019 1:06 PM
Created
Dec 15, 2019 1:05 PM
Tags
SwiftMemo
Keywords
Date
struct Box {
  var name: String
  var computed: String {
    get {
      name
    }
    set {
      
    }
  }
}

func _getPointer<T>(_ pointer: UnsafeMutablePointer<T>) -> UnsafeMutablePointer<T> {
  pointer
}

var box = Box(name: "Hello")

do {
  let p = _getPointer(&box.name)
  p.pointee
  p.pointee = "Muuk"
  p.pointee
}