Skip to content

Instantly share code, notes, and snippets.

View rainris's full-sized avatar
😑
At Work

Kwon O Jin / RAIN rainris

😑
At Work
View GitHub Profile
#!/bin/bash
brew_command=/usr/local/bin/brew
brew_cask_command="$brew_command cask"
echo '#!/bin/bash'
echo ''
echo 'trap ctrl_c INT'
echo 'function ctrl_c() {'
echo 'echo "** Trapped CTRL-C"'
@emaloney
emaloney / guard-closure.md
Last active August 1, 2023 00:24
A simplified notation for avoiding the weak/strong dance with closure capture lists

Simplified notation for avoiding the [weak self]/strongSelf dance with closures

  • Proposal: TBD
  • Author: Evan Maloney
  • Status: Draft
  • Review manager: TBD

Introduction

Frequently, closures are used as completion callbacks for asynchronous operations, such as when dealing with network requests. It is quite common to model these sorts of operations in such a way that an object instance represents a request/response transaction, for example:

@mattrubin
mattrubin / WeakClassProtocol.swift
Last active August 12, 2017 21:13
Swift weak var of protocol type (No @objc required)
import UIKit
// A swift protocol can apply to a class, struct, or enum,
// but only a reference type can be stored in a `weak` var,
// so a weak var cannot be of a typical protocol type.
protocol MyProcotol {
}