Skip to content

Instantly share code, notes, and snippets.

@victor
Created October 14, 2015 19:27
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save victor/81bec4dc4ae0a483b388 to your computer and use it in GitHub Desktop.
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)
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