Skip to content

Instantly share code, notes, and snippets.

View zeeshankhan's full-sized avatar
🏠
Working from home

Zeeshan Khan zeeshankhan

🏠
Working from home
View GitHub Profile
@ole
ole / UIAlertController+TextField.swift
Last active September 13, 2022 14:20
A UIAlertController with a text field and the ability to perform validation on the text the user has entered while the alert is on screen. The OK button is only enabled when the entered text passes validation. More info: https://oleb.net/2018/uialertcontroller-textfield/
import UIKit
/// A validation rule for text input.
public enum TextValidationRule {
/// Any input is valid, including an empty string.
case noRestriction
/// The input must not be empty.
case nonEmpty
/// The enitre input must match a regular expression. A matching substring is not enough.
case regularExpression(NSRegularExpression)
@LeeKahSeng
LeeKahSeng / webview-inject-javascript-full.swift
Last active February 27, 2023 17:41
Sample code for "Injecting JavaScript Into Web View In iOS" (https://swiftsenpai.com/development/web-view-javascript-injection/)
import UIKit
import WebKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Configure the web view for JavaScript injection
configureWebView()
@chriseidhof
chriseidhof / .swiftlint.yml
Created February 7, 2023 09:59
SwiftLint rules for state, state object, environment and scaled metric
disabled_rules:
- trailing_comma
opt_in_rules:
- file_header
file_header:
forbidden_pattern: /./
custom_rules:
state_private:
name: "Private SwiftUI State"
regex: "\\@State\\s*var"