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 SomeDeserializer<T>: JsonDeserializer { | |
private let deserializer: JsonDeserializer | |
init<D: JsonDeserializer>(deserializer: D) where D.Response == T { | |
self.deserializer = deserializer | |
} | |
func parse(json: [String : Any]) -> T { | |
return deserializer.parse(json: json) | |
} |
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 SomeDeserializer<T, D: JsonDeserializer>: JsonDeserializer { | |
private let deserializer: D | |
init<D: JsonDeserializer>(deserializer: D) where D.Response == T { | |
self.deserializer = deserializer | |
} | |
func parse(json: [String : Any]) -> T { | |
return deserializer.parse(json: json) | |
} |
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 BaseJsonDeserializer<T>: JsonDeserializer { | |
init() { | |
guard type(of: self) != BaseJsonDeserializer.self | |
else { fatalError("do not initialize this abstract class directly") } | |
} | |
func parse(json: [String : Any]) -> T { | |
fatalError("Abstract class. Subclass must override") | |
} | |
} |
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
public enum Result<T, E: Error> { | |
case success(T) | |
case failure(E) | |
} | |
public enum NetworkError: Error { | |
case invalidJson | |
case badRequest | |
case timeout | |
} |
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 IdentifiableDispatchQueue { | |
let key = DispatchSpecificKey<UUID>() | |
let id = UUID() | |
let queue: DispatchQueue | |
convenience init(label: String) { | |
let queue = DispatchQueue(label: label) | |
self.init(queue: queue) |
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 android.support.test.espresso.ViewAction | |
import android.support.test.espresso.ViewInteraction | |
import android.support.test.espresso.action.CoordinatesProvider | |
import android.support.test.espresso.UiController | |
import android.view.InputDevice | |
import android.view.MotionEvent | |
import android.os.SystemClock | |
class MultiTouchDownEvent : ViewAction { |
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
//: Playground - noun: a place where people can play | |
import UIKit | |
import PlaygroundSupport | |
func setUpDemo() { | |
let testContents = """ | |
This is a test | |
Emojis follow: | |
🚀 |
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 ChatCell: UITableViewCell { | |
lazy var iconImageView: UIImageView = { | |
let imageView = UIImageView() | |
let icon = UIImage(named: "icons8-Sheep on Bike") | |
imageView.translatesAutoresizingMaskIntoConstraints = false | |
imageView.backgroundColor = .clear | |
imageView.layer.cornerRadius = 25 | |
imageView.contentMode = .scaleAspectFit |
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 PermaColorView: UIView { | |
var color: UIColor = .clear { | |
didSet { | |
backgroundColor = color | |
} | |
} | |
override var backgroundColor: UIColor? { |
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 Filter<Object> { | |
let path: PartialKeyPath<Object> | |
let matcher: (Any) -> Bool | |
init<Type>(keyPath: KeyPath<Object, Type>, matcher: @escaping (Type) -> Bool) { | |
self.path = keyPath | |
self.matcher = { value in | |
guard let typedValue = value as? Type else { return false } | |
return matcher(typedValue) |