Skip to content

Instantly share code, notes, and snippets.

@aleclarson
Created August 9, 2014 04:29
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 aleclarson/53cc437e4e4a0daf9ed9 to your computer and use it in GitHub Desktop.
Save aleclarson/53cc437e4e4a0daf9ed9 to your computer and use it in GitHub Desktop.
Byte Array to NSData
// This goes in an NSData extension
convenience init (byteArray: [NSNumber]) {
let bytes = byteArray.combine([]) {
(n, inout b: [Byte], _, _) in
b.append(n.unsignedCharValue)
}
self.init(bytes: bytes, length: bytes.count)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment