Skip to content

Instantly share code, notes, and snippets.

import UIKit
class PathBuilder {
private var components: [String] = []
private var pathBase: String
init(pathBase: String) {
self.pathBase = pathBase
}
class LinkedList<T>: Collection {
typealias Element = T
typealias Index = Int
typealias Iterator = IteratorImpl
final class IteratorImpl: IteratorProtocol {
typealias Element = T
private var cursor: Node?
class Trulean<T> {
class Empty: Trulean<T> {
override func onFalse(_ eval: @autoclosure () throws -> T) rethrows -> T {
return try eval()
}
}
class Full: Trulean<T> {
let _value: T
class TrackSelectionStrategy {
static let straight: TrackSelectionStrategy = Straight()
static let shuffle: TrackSelectionStrategy = Shuffle()
fileprivate init() {}
func nextItem(_ sender: AudioPlayerImpl) -> AudioPlayerItem? {
return self.nextItemIndex(sender).map({ sender._items[$0] })
}
protocol DomainEvent {
typealias Subscription = (Self) -> Void
static var notificationName: Notification.Name { get }
}
let DomainEventKey = "DomainEventKey"
import Foundation
import UIKit
class RTTableViewControllerSectionModel: NSObject {
let cellModels: [RTTableViewControllerCellModel]
let tableView: UITableView
required init(_ tableView: UITableView, _ cellModels: [RTTableViewControllerCellModel]) {
self.tableView = tableView
func performWithErrorPointer<T>(_ executable: @autoclosure @escaping () throws -> T, _ errorPointer: NSErrorPointer) -> T? {
do {
return try executable()
}
catch let error {
errorPointer?.pointee = error as NSError
return nil
}
}
import UIKit
class TableViewContainerCell<Content: UIView>: UITableViewCell {
var content: Content
override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
if let viewFromNib = Content.loadDefaultNib() {
content = viewFromNib
}
class Logger {
static var defaultLogger = Logger()
func log(_ message: String) {
print(message)
}
}
import Foundation
class CancellableDecorator {
private class Token {
var isValid = true
}
private var token: Token?