Skip to content

Instantly share code, notes, and snippets.

@Danappelxx
Created March 19, 2016 19:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Danappelxx/b4ca59ab5d3726a00e22 to your computer and use it in GitHub Desktop.
Save Danappelxx/b4ca59ab5d3726a00e22 to your computer and use it in GitHub Desktop.
let length = 10
let ptr = UnsafeMutablePointer<UInt8>(allocatingCapacity: length)
defer { ptr.deallocateCapacity(length) }
for i in 0..<length {
ptr.advanced(by: i).pointee = UInt8(i)
}
let buffer = UnsafeMutableBufferPointer(start: ptr, count: length)
let arr = Array(buffer)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment