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
extension Binding { | |
/// like Binding.constant but lets you update the value and stores that updated value via a captured enclosing reference. | |
public static func initially(_ value: Value) -> Binding<Value> { | |
let box = Box(value) | |
return .init( | |
get: { box.value }, | |
set: { box.value = $0 } | |
) | |
} |
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
enum JSONValue: Codable, Equatable { | |
struct JSONValueDecodingError: Error { | |
let message: String | |
} | |
case boolean(Bool) | |
case number(Double) | |
case string(String) | |
case array([JSONValue?]) | |
case object([String: JSONValue?]) |
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
// these functions take a swift class's statically referenced method and the instance those methods | |
// should apply to, and returns a function that weakly captures the instance so that you don't have | |
// to worry about memory retain cycles if you want to directly use an instance method as a handler | |
// for some object, like NSNotificationCenter. | |
// | |
// For more information, see this post: | |
// http://www.klundberg.com/blog/capturing-objects-weakly-in-instance-method-references-in-swift/ | |
func weakify <T: AnyObject, U>(owner: T, f: T->U->()) -> U -> () { | |
return { [weak owner] obj in |
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
// Available variables: | |
// - Machine | |
// - interpret | |
// - assign | |
// - send | |
// - sendParent | |
// - spawn | |
// - raise | |
// - actions |
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
public struct OptionalIndex<InnerIndex: Comparable> { | |
let inner: InnerIndex? | |
init(_ base: InnerIndex) { | |
inner = base | |
} | |
init() { | |
inner = nil | |
} |
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
extension Optional: Collection where Wrapped: Collection { | |
public typealias Element = Wrapped.Element | |
public typealias Index = Wrapped.Index | |
public func index(after i: Wrapped.Index) -> Wrapped.Index { | |
switch self { | |
case let value?: | |
return value.index(after: i) | |
case nil: | |
fatalError() // TODO: ??? |
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
041f94dcd6f7e66679da2ead9c76e5aaa24f0d17ec559ab354806133340f877095226f2d4bc36a07c4cf1f1e9269bb3bb55970234a0af292c869446ce0f6e8e886;nsirlconnection |
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
{% for type in types.based.Codable|!enum %} | |
public extension {{ type.name }} { | |
enum CodingKeys: String, CodingKey { | |
{% for variable in type.variables|instance %} | |
{% if variable|annotated:"keyOverride" %} | |
case {{ variable.name }} = "{{ variable.annotations.keyOverride }}" | |
{% else %} | |
case {{ variable.name }} = "{{ variable.name|camelToSnakeCase }}" | |
{% endif %} | |
{% endfor %} |
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
/usr/bin/xcrun xcodebuild -workspace /Users/klundberg/workspaces/wayfair-ios/Carthage/Checkouts/FutureKit/FutureKit.xcworkspace -scheme FutureKit\ iOS -configuration Release -derivedDataPath /Users/klundberg/Library/Caches/org.carthage.CarthageKit/DerivedData/FutureKit/3.0.0 -sdk iphoneos ONLY_ACTIVE_ARCH=NO BITCODE_GENERATION_MODE=bitcode CODE_SIGNING_REQUIRED=NO CODE_SIGN_IDENTITY= CARTHAGE=YES clean buildUser defaults from command line: | |
IDEDerivedDataPathOverride = /Users/klundberg/Library/Caches/org.carthage.CarthageKit/DerivedData/FutureKit/3.0.0 | |
Build settings from command line: | |
BITCODE_GENERATION_MODE = bitcode | |
CARTHAGE = YES | |
CODE_SIGN_IDENTITY = | |
CODE_SIGNING_REQUIRED = NO | |
ONLY_ACTIVE_ARCH = NO | |
SDKROOT = iphoneos11.0 |
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
// Written using Swift 3.0.x | |
fileprivate final class Box<T> { | |
let unbox: T | |
init(_ value: T) { | |
unbox = value | |
} | |
} | |
public struct CopyOnWrite<T: AnyObject> { |
NewerOlder