Created
October 14, 2015 19:27
-
-
Save victor/81bec4dc4ae0a483b388 to your computer and use it in GitHub Desktop.
Simpler way to obtain a String from a byte array (such as a device token)
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
import UIKit | |
let bytes: [UInt8] = [0xDE, 0xAD, 0xBE, 0xEF, 0x42] | |
let hex = bytes.reduce("", combine: { $0 + String($1, radix:16, uppercase:true) }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment