Skip to content

Instantly share code, notes, and snippets.

View calosth's full-sized avatar
🏠
Working from home

Carlos Linares calosth

🏠
Working from home
View GitHub Profile
@phatmann
phatmann / BackgroundTask.swift
Created April 15, 2015 03:14
Encapsulate iOS background tasks in a Swift class
class BackgroundTask {
private let application: UIApplication
private var identifier = UIBackgroundTaskInvalid
init(application: UIApplication) {
self.application = application
}
class func run(application: UIApplication, handler: (BackgroundTask) -> ()) {
// NOTE: The handler must call end() when it is done

Introducing a 🐶🐮 (Syntax.DogCow) Literal

  • Proposal: SE-M00F
  • Author: Erica Sadun
  • Status: Draft
  • Review manager: Crusty

Introduction

When not bound as a symbol, this proposal allows the "dogcow" literal to be used in place of otherwise unspecified values. Swift infers a value to substitute, automatically introducing the most appropriate value at any use point.

@chriseidhof
chriseidhof / parsers.swift
Last active December 28, 2020 04:36
Faster Parsers
//
// Operators.swift
// FastParsing
//
// Created by Chris Eidhof on 26/12/2016.
// Copyright © 2016 objc.io. All rights reserved.
//
// TODO: give appropriate credit. Many parts were stolen from SwiftParsec.
import Foundation
import UIKit
struct ViewStyle<T> {
let style: (T) -> Void
}
let filled = ViewStyle<UIButton> {
$0.setTitleColor(.white, for: .normal)
$0.backgroundColor = .red