Skip to content

Instantly share code, notes, and snippets.

View DevAndArtist's full-sized avatar
🦅
Hacking in Swift

Adrian M. DevAndArtist

🦅
Hacking in Swift
View GitHub Profile
@DevAndArtist
DevAndArtist / swiftui_to_uikit.swift
Last active July 8, 2019 10:02
Applying SwiftUI ideas to UIKit
import RxSwift
import RxCocoa
import RxRelay
extension Disposable {
public func wrapIntoAnyDisposable() -> AnyDisposable {
return AnyDisposable(self)
}
}

Application Development Techniques

Drivable UI

@dynamicMemberLookup
struct DriverFor<Base> {
 var base: Base
@DevAndArtist
DevAndArtist / Property Delegates.md
Last active March 24, 2019 10:38
Property Delegates
public struct Unique<Key, Value>: Hashable where Key: Hashable {
public enum KeyVariant {
case key(Key)
case keyPath(KeyPath<Value, Key>)
case closure((Value) -> Key)
internal func _key(for value: Value) -> Key {
switch self {
case .key(let key):
@DevAndArtist
DevAndArtist / deinit-experiment.swift
Created September 13, 2018 14:25
Deinit experiement
class Ref {
weak var obj: Obj? {
didSet { print("didSet", obj as Any) }
}
}
class Obj {
weak var ref: Ref?
func unlink(from ref: Ref) {
public enum Foo : OptionSet {
case a
case b
case value(UInt8)
public var rawValue: UInt8 {
switch self {
case .a:
protocol ValueContainer {
associatedtype Value
var value: Value { get }
init(_ value: Value)
}
extension ValueContainer where Self : Equatable, Value : Equatable {
static func == (lhs: Self, rhs: Self) -> Bool {
return lhs.value == rhs.value
}
import RxSwift
public final class DisposeCache<Key>
: ExpressibleByDictionaryLiteral where Key : Hashable {
///
private var lock = NSRecursiveLock()
///
private var storage: [Key: Disposable]
Path Protocol
/swift/stdlib/public/core/AnyHashable.swift:16 _HasCustomAnyHashableRepresentation
/swift/stdlib/public/core/BidirectionalCollection.swift:21 _BidirectionalIndexable
/swift/stdlib/public/core/BridgeObjectiveC.swift:19 _ObjectiveCBridgeable
/swift/stdlib/public/core/Collection.swift:20 _IndexableBase
/swift/stdlib/public/core/Collection.swift:176 _Indexable
/swift/stdlib/public/core/CompilerProtocols.swift:193 _ExpressibleByBuiltinIntegerLiteral
/swift/stdlib/public/core/CompilerProtocols.swift:240 _ExpressibleByBuiltinFloatLiteral
/swift/stdlib/public/core/CompilerProtocols.swift:283 _ExpressibleByBuiltinBooleanLiteral
import UIKit

protocol ViewComponent : AnyObject {
  ///
  func isAncestor(of descendant: Self) -> Bool

  ///
  func isDescendant(of ancestor: Self) -> Bool