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 | |
import MobileCoreServices | |
class PastePlan: NSObject, NSItemProviderReading, NSItemProviderWriting, Codable { | |
let plan: Plan | |
init(_ plan: Plan) { | |
self.plan = plan | |
} | |
static var readableTypeIdentifiersForItemProvider: [String] = [(kUTTypeJSON) as String] | |
static var writableTypeIdentifiersForItemProvider: [String] = [(kUTTypeJSON) as String] |
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 | |
import PlaygroundSupport | |
precedencegroup ForwarderApplication { | |
associativity: left | |
} | |
infix operator |> : ForwarderApplication | |
func |> <A, B>(x: A, f: (A) -> B) -> B { | |
return f(x) | |
} |
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
func weakToStrong<T: AnyObject>(on target: T, block: ((T) -> Void)?) -> Void { | |
return { [weak target] in | |
guard let target = target else { | |
return | |
} | |
block?(target) | |
}() | |
} |
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 | |
import PlaygroundSupport | |
struct Decorator<View: UIView> { | |
let decorate: (View) -> View | |
} | |
func decorate<View: UIView>(_ view: View, with decorator: Decorator<View>) -> View { | |
return decorator.decorate(view) | |
} |
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
// https://medium.com/halcyon-mobile/view-decoration-in-swift-4023a68be5d3 | |
import UIKit | |
import PlaygroundSupport | |
protocol ViewDecorator { | |
associatedtype View: UIView | |
func decorate(view: View) | |
} |