Skip to content

Commit 6618a48

Browse files
Merge pull request #172 from Iterable/bug/mob-764-hex-conversion
[MOB-764] - hex conversion
2 parents 8d4c7e4 + d55dcde commit 6618a48

File tree

1 file changed

+1
-11
lines changed

1 file changed

+1
-11
lines changed

swift-sdk/Internal/ClassExtensions.swift

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,6 @@ public extension Bundle {
3737
public extension Data {
3838
//from: https://stackoverflow.com/questions/39075043/how-to-convert-data-to-hex-string-in-swift
3939
func hexString() -> String {
40-
let digits = Array("01234567890abcdef".utf16)
41-
42-
var chars: [UniChar] = []
43-
chars.reserveCapacity(count * 2)
44-
45-
for byte in self {
46-
chars.append(digits[Int(byte / 16)])
47-
chars.append(digits[Int(byte % 16)])
48-
}
49-
50-
return String(utf16CodeUnits: chars, count: chars.count)
40+
return map { String(format: "%02.2hhx", $0) }.joined()
5141
}
5242
}

0 commit comments

Comments
 (0)