View DeselectRowViewWillAppear.swift
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
if let selectedIndexPath = methodsTableView?.indexPathForSelectedRow { | |
if let coordinator = transitionCoordinator { | |
coordinator.animate(alongsideTransition: { context in | |
self.methodsTableView?.deselectRow(at: selectedIndexPath, animated: true) | |
}) { context in | |
if context.isCancelled { | |
self.methodsTableView?.selectRow(at: selectedIndexPath, animated: false, scrollPosition: .none) | |
} | |
} | |
} else { |
View CurrentValue.swift
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 | |
/// An object that wraps a single value and publishes a new element whenever the value changes. | |
@propertyWrapper struct CurrentValue<Output> { | |
private let publisher = BasicPublisher() | |
var value: Output { | |
didSet { | |
publisher.handler?(oldValue, wrappedValue) | |
} |
View safeTest.swift
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 | |
import XCTest | |
extension Collection where Indices.Iterator.Element == Index { | |
subscript(safe index: Index) -> Iterator.Element? { | |
return indices.contains(index) ? self[index] : nil | |
} | |
} | |
class PerfomanceTester: XCTestCase { |
View Package.swift
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
// swift-tools-version:4.0 | |
import PackageDescription | |
#if os(Linux) | |
import Glibc | |
#else | |
import Darwin.C | |
#endif | |
enum Enviroment: String { |
View SingleFetchedResultController.swift
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 CoreData | |
protocol SingleFetchedResultsControllerDelegate: class { | |
func controller(didChange anObject: NSFetchRequestResult, for type: SingleFetchedResultsChangeType) | |
func controller(error: SingleFetchedResultsControllerError) | |
} | |
extension SingleFetchedResultsControllerDelegate { | |
func controller(_ controller: SingleFetchedResultsController<NSFetchRequestResult>, error: SingleFetchedResultsControllerError) { } | |
} |
View KeyboardChangeFrameObserver.swift
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 UIKit | |
/// Observer that will fire events when keyboard frame will be changed (shown, hidden or resized) | |
/// - Note: Call `addKeyboardFrameChangesObserver()` on init, e.g. on `viewWillAppear` | |
/// and `removeKeyboardFrameChangesObserver()` on deinit, e.g. on `viewDidDisappear` | |
public protocol KeyboardChangeFrameObserver: class { | |
func willChangeKeyboardFrame(height: CGFloat, animationDuration: TimeInterval, animationOptions: UIView.AnimationOptions) | |
} | |
public extension KeyboardChangeFrameObserver { |
View FRCCollectionViewDataSource.swift
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
protocol FRCCollectionViewDelegate: class { | |
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell | |
} | |
class FRCCollectionViewDataSource<FetchRequestResult: NSFetchRequestResult>: NSObject, UICollectionViewDataSource, NSFetchedResultsControllerDelegate { | |
let frc: NSFetchedResultsController<FetchRequestResult> | |
weak var collectionView: UICollectionView? | |
weak var delegate: FRCCollectionViewDelegate? | |
View AsynchronousOperation.swift
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 Vasily Ulianov on 09.02.17, updated in 2019. | |
// License: MIT | |
import Foundation | |
/// Subclass of `Operation` that adds support of asynchronous operations. | |
/// 1. Call `super.main()` when override `main` method. | |
/// 2. When operation is finished or cancelled set `state = .finished` or `finish()` | |
open class AsynchronousOperation: Operation { | |
public override var isAsynchronous: Bool { |
NewerOlder