Skip to content

Instantly share code, notes, and snippets.

Adrian Śliwa adiki

Block or report user

Report or block adiki

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View ThreadSafe.swift
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 }
}
View objects.swift
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)
View Layout.swift
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
View FeedView.swift
class FeedView: UIView {
let collectionView = UICollectionView(frame: .zero, collectionViewLayout: GiftainerLayout())
let tooltipView = TooltipView()
init() {
super.init(frame: .zero)
addSubviews()
}
View KeyboardNotifications.swift
class FeedViewController {
private let referencesBag = ReferencesBag()
private var tokens: [Token] = []
override func viewDidLoad() {
super.viewDidLoad()
setupApplicationNotifications()
}
}
View ReferencesBag.swift
class ReferencesBag {
private var references: [AnyObject] = []
func append(_ reference: AnyObject) {
references.append(reference)
}
}
// For details about Token class please visit this address :
View SizeClassView.swift
import UIKit
class SizeClassView: UIView {
private var regularHeightConstraints = [NSLayoutConstraint]()
private var compactHeigthConstraints = [NSLayoutConstraint]()
func addRegularHeightConstraint(regularHeightConstraint: NSLayoutConstraint) {
regularHeightConstraints.append(regularHeightConstraint)
addConstraint(regularHeightConstraint)
You can’t perform that action at this time.