This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ReactiveSwift | |
import ReactiveCocoa | |
import Kingfisher | |
extension Kingfisher: ReactiveExtensionsProvider { } | |
extension Reactive where Base == Kingfisher<UIImageView> { | |
var image: BindingTarget<URL?> { | |
return makeBindingTarget { | |
$0.setImage(with: $1) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import LocalAuthentication | |
extension LAContext { | |
/// BiometryType that works on iOS versions older than iOS 11. | |
var compatBiometryType: BiometryType { | |
var authError: NSError? | |
guard canEvaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, error: &authError), authError == nil else { return .none } | |
// On iOS 11 we can get the biometry type directly. | |
if #available(iOS 11.0, *) { | |
switch biometryType { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func isGermanTin(tin: String) -> Bool { | |
let endIndex = tin.index(tin.startIndex, offsetBy: 10) | |
let tinNumbers = tin[..<endIndex].compactMap { Int(String($0)) } | |
// First number can't be 0 | |
guard tinNumbers.first != 0 else { return false } | |
// There should be exactly 8 or 9 unique numbers and exactly one that has 2 occurrances | |
let occurances = tinNumbers.reduce(into: [:]) { $0[$1, default: 0] += 1 } | |
guard 8...9 ~= occurances.keys.count else { return false } | |
let occurranceCount = occurances.keys.count == 9 ? 2 : 3 | |
guard occurances.values.contains(where: { $0 == occurranceCount }) else { return false } |
OlderNewer