Skip to content

Instantly share code, notes, and snippets.

View davidlawson's full-sized avatar

David Lawson davidlawson

  • Melbourne, Australia
View GitHub Profile
@rgcottrell
rgcottrell / gist:c42e62d1f09e711f54b5
Created June 21, 2014 15:01
Unwrapping Multiple Swift Optionals
// NOTE: @schwa figured this out, but I'm claiming some of the credit for asking the question.
// See https://gist.github.com/schwa/ecd5f8c154e60fcb0f58 for the original solution.
// Playground - noun: a place where people can play
import Foundation
// Implementation (repeat as needed for number of parameters).
func unwrap<T1, T2>(p1: T1?, p2: T2?) -> (T1, T2)? {
@davidlawson
davidlawson / BadgeBarButtonItem.swift
Last active November 20, 2024 22:07
UIBarButtonItem with badge, Swift 4, iOS 9/10/11
import UIKit
public class BadgeBarButtonItem: UIBarButtonItem
{
@IBInspectable
public var badgeNumber: Int = 0 {
didSet {
self.updateBadge()
}
}