Hot | Cold | Notes | |
---|---|---|---|
Behaviors | Always | Property values over time | |
Events | Maybe | Maybe | This is a design decision, but picking “hot” requires introducing some concept of buffering |
Promises | Sorta | Sorta | Promises don't do work until started, but only do it once, and share/buffer their result |
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
// | |
// LCKIndexedFetchedResultsController.h | |
// Quotebook | |
// | |
// Created by Andrew Harrison on 7/26/14. | |
// Copyright (c) 2014 Lickability. All rights reserved. | |
// | |
@import CoreData; |
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
//: Playground - noun: a place where people can play | |
// Got most of it from: | |
// https://developer.apple.com/sample-code/wwdc/2015/downloads/Crustacean.zip | |
// This is in the Protocol-Oriented Programming in Swift talk | |
// Pay special attention to the Heterogeneous Equality section, on page 2. | |
// | |
// Most comments directly copy/pasted from Crustacean Playground | |
protocol Account { |
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
static NSData *PSPDFCalculateSHA256FromFileURL(NSURL *fileURL, CC_LONG dataLength, NSError **error) { | |
NSCParameterAssert(fileURL); | |
NSData *shaData; | |
int fd = open(fileURL.path.UTF8String, O_RDONLY); | |
if (fd < 0) { | |
if (error) *error = [NSError pspdf_errorWithCode:PSPDFErrorCodeUnableToOpenPDF description:@"Failed to open file for calculating SHA256."]; | |
return 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
protocol TextContaining { | |
var isEmpty: Bool { get } | |
} | |
extension String: TextContaining { | |
} | |
extension Optional where Wrapped: TextContaining { | |
var isEmpty: Bool { | |
switch self { |
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 <Foundation/Foundation.h> | |
@interface MySingleton : NSObject | |
+(instancetype) sharedInstance; | |
// clue for improper use (produces compile time error) | |
+(instancetype) alloc __attribute__((unavailable("alloc not available, call sharedInstance instead"))); | |
-(instancetype) init __attribute__((unavailable("init not available, call sharedInstance instead"))); | |
+(instancetype) new __attribute__((unavailable("new not available, call sharedInstance instead"))); |
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
//===----------------------------------------------------------------------===// | |
//===--- Defining Collections, easy as Pie --------------------------------===// | |
//===----------------------------------------------------------------------===// | |
struct Digits : PieCollection { | |
let startState: Optional = 0 | |
func iterate(from state: Int) -> (nextState: Int?, element: Int) { | |
return (nextState: state+1 < 10 ? state+1 : nil, element: state) | |
} | |
} |
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
final class CenteringView: UIView { | |
// MARK: - Initialization | |
init(contentView: UIView) { | |
super.init(frame: .zero) | |
addSubview(contentView) | |
contentView.translatesAutoresizingMaskIntoConstraints = false | |
NSLayoutConstraint.activateConstraints([ |
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 Foundation | |
import JavaScriptCore | |
/// Used to lookup our Bundle. | |
private class MomentBundleClass: NSObject {} | |
/// A wrapper around a moment.js object. | |
public struct Moment { |
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
// Variables just contain an integer. We can have a maximum of `Int.max` variables in our program. ¯\_(ツ)_/¯ | |
private struct Var { | |
static var freshVarIx = 0 | |
let ix: Int | |
init() { | |
Var.freshVarIx+=1 | |
ix = Var.freshVarIx | |
} | |
} |
OlderNewer