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
protocol Copyable { | |
typealias CopyType | |
func copy() -> CopyType | |
} | |
class A: Copyable { | |
var x: Int | |
init(x: Int) { self.x = x } | |
func copy() -> A { |
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
//: [Previous](@previous) | |
import UIKit | |
import Behavior | |
import XCPlayground | |
//: ## Task: Create a small counter application | |
//: This approach uses ports and behaviors | |
struct Counter { |
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
// events | |
public struct ComponentEvents { | |
public var appEvent = Port<(component: Component, event: EventType)>() | |
} | |
subcomponent.events.appEvent.subscribe { component, event in | |
self.applicationEvent(component, event: event) | |
} | |
func applicationEvent(component: Component, event: Event) { |
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
struct ModifyBehavior { | |
var value: Int | |
static var operation1: (inout ModifyBehavior) -> Int = { instance in | |
instance._operationToUse = operation2 | |
return instance.value | |
} | |
static var operation2: (inout ModifyBehavior) -> Int = { instance in | |
instance.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
// embed in the target (note props are read only) | |
protocol MySensor { | |
var name: String { get } | |
var age: Int { get } | |
} | |
// an example target that holds sensor | |
protocol MyView { | |
var sensor: MySensor { get set } | |
} |
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
#!/bin/bash | |
# This script downloads and builds the iOS, tvOS and Mac openSSL libraries with Bitcode enabled | |
# Credits: | |
# https://github.com/st3fan/ios-openssl | |
# https://github.com/x2on/OpenSSL-for-iPhone/blob/master/build-libssl.sh | |
# https://gist.github.com/foozmeat/5154962 | |
# Peter Steinberger, PSPDFKit GmbH, @steipete. | |
# Felix Schwarz, IOSPIRIT GmbH, @felix_schwarz. |
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
javascript:(function(){document.querySelectorAll("video").forEach(function(video){if(window.getComputedStyle(video).display!=='none'){video.webkitSetPresentationMode("picture-in-picture");}});})(); |