Skip to content

Instantly share code, notes, and snippets.

@jaz303
Last active February 28, 2016 02:27
Show Gist options
  • Save jaz303/de5e297d9750830b7d2f to your computer and use it in GitHub Desktop.
Save jaz303/de5e297d9750830b7d2f to your computer and use it in GitHub Desktop.
// I assume this is horribly illegal but it seems to work!
// NB. array size is fixed at creation time; it will never change.
// Also... source array is class instance variable.
func cast<T>(inout ary: Array<UInt8>) -> UnsafeMutablePointer<T> {
var ptr: COpaquePointer = nil
ary.withUnsafeMutableBufferPointer { (tmp) in
ptr = COpaquePointer(tmp.baseAddress)
}
return UnsafeMutablePointer<T>(ptr)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment