Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

final class ThreadSafe<T> {
private var _value: T
private let queue = DispatchQueue(label: ThreadSafe.description())
init(_ value: T) {
self._value = value
}
var value: T {
return queue.sync { _value }
}
let gifsProvider: AnyObjectsProvider<GIF> = objectsManager.makeGIFsProvider()
protocol ObjectsManager {
var defaultGIFPredicate: NSPredicate { get }
func makeGIFsProvider() -> AnyObjectsProvider<GIF>
func save(gifs: [GIF]) -> Completable
func hide(gif: GIF)
import UIKit
typealias Constraint = (_ child: UIView, _ other: UIView) -> NSLayoutConstraint
func equal<Axis, Anchor>(_ keyPath: KeyPath<UIView, Anchor>, constant: CGFloat = 0, priority: UILayoutPriority = .required) -> [Constraint] where Anchor: NSLayoutAnchor<Axis> {
return equal(keyPath, keyPath, constant: constant, priority: priority)
}
func equal<Axis, Anchor>(_ keyPath: KeyPath<UIView, Anchor>, _ toAnchor: KeyPath<UIView, Anchor>, constant: CGFloat = 0, priority: UILayoutPriority = .required) -> [Constraint] where Anchor: NSLayoutAnchor<Axis> {
return [{ view, other in
class FeedView: UIView {
let collectionView = UICollectionView(frame: .zero, collectionViewLayout: GiftainerLayout())
let tooltipView = TooltipView()
init() {
super.init(frame: .zero)
addSubviews()
}
class FeedViewController {
private let referencesBag = ReferencesBag()
private var tokens: [Token] = []
override func viewDidLoad() {
super.viewDidLoad()
setupApplicationNotifications()
}
}
class ReferencesBag {
private var references: [AnyObject] = []
func append(_ reference: AnyObject) {
references.append(reference)
}
}
// For details about Token class please visit this address :
import UIKit
class SizeClassView: UIView {
private var regularHeightConstraints = [NSLayoutConstraint]()
private var compactHeigthConstraints = [NSLayoutConstraint]()
func addRegularHeightConstraint(regularHeightConstraint: NSLayoutConstraint) {
regularHeightConstraints.append(regularHeightConstraint)
addConstraint(regularHeightConstraint)