diff --git a/Trust/Extensions/Int.swift b/Trust/Extensions/Int.swift new file mode 100644 index 000000000..a9f39a208 --- /dev/null +++ b/Trust/Extensions/Int.swift @@ -0,0 +1,9 @@ +// Copyright SIX DAY LLC. All rights reserved. + +import Foundation + +extension Int { + func toBool() -> Bool { + return (self as NSNumber).boolValue + } +} diff --git a/Trust/Extensions/String.swift b/Trust/Extensions/String.swift index 41074f426..a2cd8e478 100644 --- a/Trust/Extensions/String.swift +++ b/Trust/Extensions/String.swift @@ -54,6 +54,15 @@ extension String { var add0x: String { return "0x" + self } + + func toInt() -> Int? { + return Int(self) ?? nil + } + + func toBool() -> Bool { + return (self.toInt()?.toBool())! + } + } extension String {