Skip to content

Instantly share code, notes, and snippets.

class FormFieldNavigator {
//...
func update() {
guard let view = view else { return }
inputs = allInputs(view: view)
inputs.sort { view1, view2 in
let view1Frame = view1.convert(CGPoint.zero, to: nil)
let view2Frame = view2.convert(CGPoint.zero, to: nil)
class AppDelegate {
func appDidFinishLaunching() {
//Before the app shows root view controller, check for an override style.
window = UIWindow()
if let override = UserDefaults.standard.bool(forKey: "OverrideStyle") {
//There was an override set, use that otherwise use the system appearance
window?.overrideUserInterfaceStyle = override ? .dark : .light
}
}
}
final class NSRegex {
private let regex:NSRegularExpression
private let subject:String
private var matches:[NSTextCheckingResult] = []
init(regex:NSRegularExpression, subject:String) {
self.regex = regex
self.subject = subject
matches = regex.matches(in: subject, range: NSRange(location: 0, length: subject.count))