This file contains hidden or 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
| // RandomDecoder.swift | |
| // Utils | |
| // | |
| // Created by Svein Halvor Halvorsen on 24/10/2019. | |
| import Foundation | |
| protocol RandomInstantiable { | |
| static func randomInstance<G: RandomNumberGenerator>(using: inout G) -> Self | |
| } |
This file contains hidden or 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
| struct AnyGenerator<Element>: GeneratorType { | |
| init<G: GeneratorType where G.Element == Element>(_ gen: G) { | |
| var gen = gen | |
| self._next = { gen.next() } | |
| } | |
| private let _next: () -> Element? | |
| func next() -> Element? { | |
| return _next() | |
| } | |
| } |
This file contains hidden or 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 UIKit | |
| @IBDesignable | |
| final class PageControl: UIPageControl { | |
| @IBInspectable var activeImage: UIImage? | |
| @IBInspectable var inactiveImage: UIImage? | |
| private func updateDotImages() { | |
| for (i, subview) in enumerate(subviews) { |
This file contains hidden or 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 | |
| struct PairGenerator<T: GeneratorType> : GeneratorType { | |
| typealias Pair = (first: T.Element?, second: T.Element?) | |
| var baseGenerator: T | |
| var previousPair: Pair | |
| init(_ baseGenerator: T) { | |
| self.baseGenerator = baseGenerator | |
| self.previousPair = (nil, nil) | |
| } |
This file contains hidden or 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 SomeClass: SomeProtocol { | |
| private var _enabled: Bool = false | |
| var enabled: Bool { | |
| @objc(isEnabled) get { return _enabled } | |
| set { _enabled = newValue } | |
| } | |
| } |
This file contains hidden or 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 UIKit | |
| class SlideOutTransitioning: NSObject, UIViewControllerTransitioningDelegate, UIViewControllerAnimatedTransitioning { | |
| private var presenting: Bool = false | |
| private let duration = 0.3 | |
| func animationControllerForPresentedController(presented: UIViewController, presentingController presenting: UIViewController, sourceController source: UIViewController) -> UIViewControllerAnimatedTransitioning? { | |
| self.presenting = true | |
| return self |