Initial commit
This commit is contained in:
35
Emoney Info/Classes/extensions/Data.swift
Executable file
35
Emoney Info/Classes/extensions/Data.swift
Executable file
@ -0,0 +1,35 @@
|
||||
|
||||
import Foundation
|
||||
import UIKit
|
||||
extension Data {
|
||||
public var bytes: [UInt8] {
|
||||
return [UInt8](self)
|
||||
}
|
||||
|
||||
func hexEncodedString() -> String {
|
||||
return map { String(format: "%02hhx", $0) }.joined()
|
||||
}
|
||||
|
||||
func makeDigitalString() -> String {
|
||||
//todo: check numeric
|
||||
var s: String = ""
|
||||
for i in 0...bytes.count-1 {
|
||||
if (bytes[i] >= 0 && bytes[i] <= 9) {
|
||||
s += String(bytes[i])
|
||||
}
|
||||
}
|
||||
return s
|
||||
}
|
||||
}
|
||||
|
||||
@available(iOS 14.0, *)
|
||||
extension UISwitch {
|
||||
|
||||
func setOnValueChangeListener(onValueChanged :@escaping () -> Void){
|
||||
self.addAction(UIAction(){ action in
|
||||
|
||||
onValueChanged()
|
||||
|
||||
}, for: .valueChanged)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user