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 Foundation | |
protocol CustomProtocol { | |
associatedtype AssociatedType | |
func foo(argument: AssociatedType) | |
} | |
//let array = [CustomProtocol]() // Gives error: Protocol 'CustomProtocol' can only be used as a generic constraint because it has Self or associated type requirements | |
public struct AnyCustomProtocol<T>: CustomProtocol { |
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
// | |
// Created by Oleksandr Glagoliev on 05/11/2018. | |
// Copyright © 2018 Oleksandr Glagoliev. All rights reserved. | |
// | |
import UIKit | |
class PlaceholderTextView: UITextView { | |
var placeholderColor: UIColor = .lightGray | |
var defaultTextColor: UIColor = .black |
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
//: Playground - noun: a place where people can play | |
import UIKit | |
/*: | |
## `Date` wrapping and convenience methods | |
*/ | |
let calendar = Calendar.current | |
extension Int { | |
public var days: DateComponents { |
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
extension CGSize { | |
enum AspectMode { | |
case fit | |
case fill | |
} | |
enum Orientation { | |
case portrait | |
case landscape | |
} |
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
class <#ClassName#>: UIView { | |
// Do not forget to wire to XIB | |
@IBOutlet var view: UIView! | |
required init?(coder aDecoder: NSCoder) { | |
super.init(coder: aDecoder) | |
loadFromNib() | |
} | |
init() { |
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
[ | |
{ | |
"id": "af", | |
"description": "Afrikaans" | |
}, | |
{ | |
"id": "af-NA", | |
"description": "Afrikaans (Namibia)" | |
}, | |
{ |
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
DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 1 /*Delay time from now*/) { | |
// Your needed function | |
} |
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
/// Sometimes we need to limit values | |
/// For instance, you are making application for the Tour De France, and | |
/// You have a variable depicting the Climb category (1..5) | |
/// Here is the place, where `Bounded` can be used | |
struct Bounded<T: Comparable> { | |
var minimum: T | |
var maximum: T | |
var value: T? { | |
willSet { |
NewerOlder