Improve NFC history readers and prepare production build
This commit is contained in:
@ -25,19 +25,25 @@ extension StringProtocol {
|
||||
}
|
||||
|
||||
func hex2decimal() -> Int {
|
||||
Int(self, radix: 16)!
|
||||
Int(self, radix: 16) ?? 0
|
||||
}
|
||||
|
||||
func hex2bin() -> String {
|
||||
return String(Int(self, radix: 16)!, radix: 2)
|
||||
guard let value = Int(self, radix: 16) else {
|
||||
return ""
|
||||
}
|
||||
return String(value, radix: 2)
|
||||
}
|
||||
|
||||
func bin2decimal() -> Int {
|
||||
return Int(self, radix: 2)!
|
||||
return Int(self, radix: 2) ?? 0
|
||||
}
|
||||
|
||||
func bin2hex() -> String {
|
||||
return String(Int(self, radix: 2)!, radix: 16)
|
||||
guard let value = Int(self, radix: 2) else {
|
||||
return ""
|
||||
}
|
||||
return String(value, radix: 16)
|
||||
}
|
||||
|
||||
func secondComplementsAmount() -> Int{
|
||||
@ -180,6 +186,9 @@ extension String {
|
||||
}
|
||||
|
||||
func subString(from: Int, to: Int) -> String {
|
||||
guard from >= 0, to >= from, from <= self.count, to <= self.count else {
|
||||
return ""
|
||||
}
|
||||
let startIndex = self.index(self.startIndex, offsetBy: from)
|
||||
let endIndex = self.index(self.startIndex, offsetBy: to)
|
||||
return String(self[startIndex..<endIndex])
|
||||
@ -213,10 +222,13 @@ extension String {
|
||||
return bytes
|
||||
}
|
||||
func localizeString(string: String) -> String {
|
||||
|
||||
let path = Bundle.main.path(forResource: string, ofType: "lproj")
|
||||
let bundle = Bundle(path: path!)
|
||||
return NSLocalizedString(self, tableName: nil, bundle: bundle!,
|
||||
guard
|
||||
let path = Bundle.main.path(forResource: string, ofType: "lproj"),
|
||||
let bundle = Bundle(path: path)
|
||||
else {
|
||||
return NSLocalizedString(self, comment: "")
|
||||
}
|
||||
return NSLocalizedString(self, tableName: nil, bundle: bundle,
|
||||
value: "", comment: "")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user