https://speakerdeck.com/gwengrid/keep-calm-and-type-erase-on
Step-By-Step, writing a type-erased wrapper class by Hector Matos
Why?! No type parameters on generic protocols pt 1 pt 2 by Russ Bishop
import Foundation | |
func genericFizzBuzz<T> (number:T, tests:Array<(T)->String?>) -> String { | |
// Run each of the defined test replacements | |
let out = tests.map { t in t(number) } | |
// convert the nil's to empty strings | |
.map { v in v ?? "" } | |
// Concatenate all the replacements together | |
.reduce("", combine: +) |
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
<plist version="1.0"> | |
<dict> | |
<key>--project-company</key> | |
<string>Elegant Chaos</string> | |
<key>--company-id</key> | |
<string>com.elegantchaos</string> | |
<key>--keep-undocumented-objects</key> | |
<false/> |
// Douglas Hill, February 2018 | |
import Foundation | |
/// Returns a localised string with the key as an enum case so the compiler checks it exists. | |
/// The enum should be automatically generated using UpdateLocalisedStringKeys.swift. | |
public func localisedString(_ key: LocalisedStringKey) -> String { | |
return Bundle.main.localizedString(forKey: key.rawValue, value: nil, table: nil) | |
} |
/* | |
ericasadun.com | |
Playground Support for NIB-based interaction: Add to playground's Sources folder | |
*/ | |
import Cocoa | |
import XCPlayground |
extension UICollectionViewFlowLayout { | |
typealias DelegateMethod<Key, Value> = ((UICollectionView, UICollectionViewLayout, Key) -> Value) | |
private var delegate: UICollectionViewDelegateFlowLayout? { | |
return collectionView?.delegate as? UICollectionViewDelegateFlowLayout | |
} | |
func retrieve<Key, Value>( |
import Foundation | |
import PlaygroundSupport | |
import SwiftUI | |
struct Content: View { | |
var body: some View { | |
Text("👋🏻, 🌍!") | |
} | |
} |
extension UILayoutPriority: ExpressibleByFloatLiteral, ExpressibleByIntegerLiteral { | |
public init(floatLiteral value: Float) { | |
self.init(rawValue: value) | |
} | |
public init(integerLiteral value: Int) { | |
self.init(rawValue: Float(value)) | |
} | |
public static func +(lhs: UILayoutPriority, rhs: UILayoutPriority) -> UILayoutPriority { |
// Note: This must be used in an Xcode project that contains a bridging header | |
// that includes <asl.h> | |
import Foundation | |
/// Provides high-level methods to access the raw data in | |
/// an ASL message. | |
struct SystemLogEntry { | |
/// Key-value pairs read from ASL message | |
let data: [String : String] |
https://speakerdeck.com/gwengrid/keep-calm-and-type-erase-on
Step-By-Step, writing a type-erased wrapper class by Hector Matos
Why?! No type parameters on generic protocols pt 1 pt 2 by Russ Bishop
#Every Single Option Under The Sun