Skip to content

Instantly share code, notes, and snippets.

@el-hoshino
Last active December 24, 2015 05:44
Show Gist options
  • Save el-hoshino/4d03dbed91fadaee2dd6 to your computer and use it in GitHub Desktop.
Save el-hoshino/4d03dbed91fadaee2dd6 to your computer and use it in GitHub Desktop.
十六進数の文字列から実際の数値を取得する ref: http://qiita.com/lovee/items/eac017d1dcaf52541d3d
let hexString = "FF"
var hex:UInt32 = 0x0
let scanner:NSScanner = NSScanner(string: hexString)
scanner.scanHexInt(&hex)
print(hex) //255
let hexString = "FF"
let hex = Int(hexString, radix: 16) ?? 0
print(hex) //255
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment