Fork me on GitHub

Swift 中指针的使用 Unsafe[Mutable]Pointer

google swift pointer

Unsafe Swift: Using Pointers And Interacting With C

Swift3 Unsafe[Mutable]Pointer

swift 指针学习记录

Array -> UnsafeMutablePointer -> Array

1
2
3
4
// swift 4.2
var initalArray = [1, 2, 3]
let pointer = UnsafeMutablePointer<Int>(&initalArray)
let array = Array(UnsafeBufferPointer(start: pointer, count: initalArray.count))
------------- 本文结束感谢您的阅读 -------------