0
我在swift2轉換UnsafeMutableRawPointer到swift3
private var RecordedDurationContext = UnsafeMutablePointer<Void>.alloc(1)
這段代碼如何轉換成swift3
我在swift2轉換UnsafeMutableRawPointer到swift3
private var RecordedDurationContext = UnsafeMutablePointer<Void>.alloc(1)
這段代碼如何轉換成swift3
private var RecordedDurationContext = UnsafeMutableRawPointer.alloc(1)
let a = UnsafeMutablePointer<Int>.allocate(capacity: 1)
a.pointee = 42
print("a's value: \(a.pointee)") // 42
a.deallocate(capacity: 1)
儘管這段代碼可能回答這個問題,但提供關於爲什麼和/或代碼如何回答這個問題的附加上下文會提高它的長期價值。 –
'公共靜態FUNC分配(字節大小:詮釋,alignedTo:智力) - > UnsafeMutableRawPointer' –
http://stackoverflow.com/questions/28744536/calloc-in-swift/41221309#41221309 – Shrawan