Skip to content

Instantly share code, notes, and snippets.

View protspace's full-sized avatar
🎯
Focusing

Yevgen Sagidulin protspace

🎯
Focusing
View GitHub Profile
@protspace
protspace / Swift_5.7_Generics
Last active June 12, 2022 09:43
Design protocol interfaces in Swift
//
// File.swift
// SP
//
// Created by Yevgen Sagidulin on 12.06.2022.
//
import Foundation
protocol AnimalFeed {
@protspace
protspace / CodabeEnum.swift
Last active June 12, 2022 09:36
Codable for enum with associated values
import Foundation
enum TargetEnum: Codable {
case first(SomeObject)
case second(OtherObject)
enum CodingKeys: CodingKey {
case first
case second
@protspace
protspace / UIAlertController+TextField.swift
Last active July 3, 2019 12:37 — forked from ole/UIAlertController+TextField.swift
Small modification of @OleB's UIAlertController extension for user authorization (login, password). Source: 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)
import UIKit
class ViewBuilder {
private var view = UIView()
func frame(_ frame: CGRect) -> ViewBuilder {
view.frame = frame
return self
}
import UIKit
extension UIView {
class func animate(_ animation: @autoclosure @escaping () -> Void, duration: TimeInterval = 0.25, delay: TimeInterval = 0) {
UIView.animate(withDuration: duration, delay: delay, animations: animation)
}
}
UIView.animate(self.label.alpha = 1)