Skip to content

Instantly share code, notes, and snippets.

Chris Dzombak cdzombak

Block or report user

Report or block cdzombak

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View Swift

Hello Everyone,

The Swift 3 release is nearing completion, so it is time to look back on the release, learn from what happened, and use it to shape what we (the Swift community) do in the year ahead. Overall, Swift 3 is going to be an absolutely amazing release, and it is impressive how much got done. Thank you to everyone who contributed to making it happen. Instead of diving into a flurry of new proposals immediately, it is important to take stock of where we are, and look at the bigger picture.

Metapoint: this email is ridiculously long and covers multiple topics. Instead of replying to it directly, it is best to start new threads on individual topics that you’d like to discuss. Just tag them with “[Swift 4]” in the subject line.

Swift 3 Retrospective

Every year of Swift’s development has been completely different from the previous one, and I expect Swift 4 to continue this trend. With a goal of learning and improving year over year, here are some observations & retrospective about Swi

View Controller.swift
protocol ThingDelegate: class {
var fooString: String { get }
func foo()
class Controller: ThingDelegate {
let fooString: String
func foo() {

Keybase proof

I hereby claim:

  • I am cdzombak on github.
  • I am dzombak ( on keybase.
  • I have a public key whose fingerprint is A2D3 B712 8258 EAF7 72B6 EB00 394E 28F2 E5BF E8EF

To claim this, I am signing this object:

View OptionalOr.swift
let nilString: String? = nil
let aString: String? = "a non-nil string"
print (nilString ?? "the string is nil")
print (aString ?? "the string is nil")
// if you don't want to use `??` …
// (inspired by Scala's Option's `getOrElse`)
extension Optional {
View OmniOutliner Selected Rows to OmniFocus.scpt
tell application id "OOut"
set doc_name to name of front document
on error
display alert "No Document Open"
end try
cdzombak / viewportfix.js
Created Sep 17, 2015
Reenable pinch-to-zoom on obnoxious sites that disable it, like The New Yorker. Convert to a bookmarklet and install via .
View viewportfix.js
var m=document.getElementsByTagName('meta');
for(var i=0; i<m.length; i++) {
if (m[i].name == 'viewport') {
if (m[i].content.indexOf('user-scalable=0') != -1 || m[i].content.indexOf('user-scalable=no') != -1) {
m[i].content = 'width=device-width, initial-scale=1.0, minimum-scale=0.5, maximum-scale=4.0, user-scalable=1';
alert('Found & fixed.');
cdzombak / CDZObjectWatcher.h
Created Jul 25, 2015
Watching Core Data objects for updates or deletions
View CDZObjectWatcher.h
// CDZObjectWatcher.h
// Created by Chris Dzombak.
// Copyright (c) 2015 Chris Dzombak. All rights reserved.
@import Foundation;
@import CoreData;
cdzombak / keyboard-autolayout.m
Last active Aug 29, 2015
iOS Keyboard Avoiding with Auto Layout
View keyboard-autolayout.m
// in -loadView or similar…
self.completeButtonBottomConstraint = [NSLayoutConstraint constraintWithItem:self.completeButton attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:v attribute:NSLayoutAttributeBottom multiplier:1.0 constant:-1.0*IDPCompleteButtonBottomSpacing];
// in -viewWillAppear:…
[NSNotificationCenter.defaultCenter addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];
[NSNotificationCenter.defaultCenter addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil];
- (void)keyboardWillShow:(NSNotification *)note {
[self updateBottomConstraintFromNotification:note];
cdzombak /
Last active Aug 29, 2015
an executive summary of my ever-forthcoming "error handling in swift 2" blog post.
  • throws in Swift 2 is just another way to return from a function/method. Because of its propagation semantics, it's not really "exceptions", which is probably a good change.
  • But unlike an Either or Result return type, throws in Swift 2 cannot communicate type information.
  • This sucks; and we will realize it sucks when we keep having to refer to documentation every time we call a function that throws to see what sort of errors we may have to handle. This is part of the problem that types solve; they are documentation, with compiler-enforced guarantees.
  • Arguments based on the clunkiness of pattern-matching on a Result type vs. the new syntax are not valid. Had the Swift team chosen to introduce a blessed stdlib Result type, they could have introduced elegant syntax to handle it without requiring boilerplate; remember, everything related to throws is new syntax.
  • Yes, this would make versioning harder. Changing the types of errors you return changes the contract of an API, if you care abou
cdzombak / Drop Action.scpt
Created Jun 3, 2015
OmniFocus AppleScript to move an action to my " Dropped" context and mark it completed.
View Drop Action.scpt
property droppedContext : "Dropped"
tell application "OmniFocus"
tell front document
set theDroppedContextID to id of item 1 of (complete droppedContext as context)
set theDroppedContext to first flattened context whose id is theDroppedContextID
on error
display alert "No context found whose name contains “" & droppedContext & ""
You can’t perform that action at this time.