This file contains hidden or 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
// | |
// SemanticVersionNumber.swift | |
// | |
// Created by Jon Cotton on 31/08/2015. | |
// | |
import Foundation | |
public struct SemanticVersionNumber { | |
let major: Int |
This file contains hidden or 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
// Copy and Paste into a Swift playground | |
import Foundation | |
import XCPlayground | |
XCPlaygroundPage.currentPage.needsIndefiniteExecution = true | |
typealias MappingDataSource = [String : AnyObject] | |
// Mappable | |
protocol Mappable { |
This file contains hidden or 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
// Copy and Paste into a Swift playground | |
import Foundation | |
import XCPlayground | |
XCPlaygroundPage.currentPage.needsIndefiniteExecution = true | |
// Data Source (anything that implements subscripting for accessing data) | |
//protocol MapDataProviding { | |
// typealias Key: Hashable |
This file contains hidden or 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
//: Adventures in generics | |
import Foundation | |
protocol MyBaseProtocol { | |
func didSomething() | |
func didAnotherThing() | |
} | |
protocol MyDataProtocol : MyBaseProtocol { |
This file contains hidden or 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 Foundation | |
import XCPlayground | |
/*: | |
# Reflux | |
*/ | |
//: Interfaces | |
protocol State { | |
init() | |
var userState: UserState {get} |
This file contains hidden or 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 AlertsStatusUpdateAction: ActionCreatingAction { | |
case requestUpdate(AlertsService) | |
case updateFinishedWithAlerts([InAppAlert]) | |
case updateFinishedWithError(AlertsError) | |
func execute(state: AppState) -> AppState { | |
var mutableState = state | |
switch self { | |
case .requestUpdate(_): |
This file contains hidden or 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/swift | |
import Foundation | |
// MARK:- Functions | |
func runShellCommand(cmd: String, env: [String : String]? = nil) -> (output: [String], error: [String], exitCode: Int32) { | |
var output : [String] = [] | |
var error : [String] = [] |
This file contains hidden or 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 CustomStringConvertible where Self: RawRepresentible, Self.RawValue == String { | |
var description: String { | |
return rawValue | |
} | |
} | |
extension CustomDebugStringConvertible where Self: RawRepresentible, Self.RawValue == String { | |
var debugDescription: String { | |
return "\(self)" | |
} |
This file contains hidden or 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
//: Playground - noun: a place where people can play | |
import UIKit | |
protocol Validator { | |
associatedtype T | |
func isValid(value: T) throws -> Bool | |
} |
This file contains hidden or 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/swift | |
import Foundation | |
enum Device: String { | |
case phone | |
case tablet | |
var videoSize: Int { | |
switch self { |
OlderNewer