Created
August 9, 2014 04:29
-
-
Save aleclarson/53cc437e4e4a0daf9ed9 to your computer and use it in GitHub Desktop.
Byte Array to NSData
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
// 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