Last active
September 26, 2015 18:17
-
-
Save chrisschreiner/d820d7c5cc4a76e20fff to your computer and use it in GitHub Desktop.
This file contains 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
// There's some function that takes an UnsafeBufferPointer | |
func f(ubp: UnsafeBufferPointer<UInt8>) | |
... | |
// I want to call it with NSData | |
let data: NSData(...) | |
f(UnsafeBufferPointer(start: UnsafePointer<UInt8>(data.bytes), count: data.length)) | |
// Would I need to NSData.withUnsafeBufferPointer() to exist? (Which of course it doesn't.) | |
// Or is there a way to convert NSData to [UInt8] without copying the data? | |
// (That feels impossible, since I can't promise [UInt8] is immutable) | |
// I'm slowly beginning to believe my use of [UInt8] is not nearly as "Swifty" as I thought, | |
// and that the correct way to hold data in Swift is NSData. I seem to constantly have little | |
// confusing corner cases every time I try to deal with [UInt8]. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment