Last active
February 28, 2016 02:27
-
-
Save jaz303/de5e297d9750830b7d2f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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