Skip to content

Instantly share code, notes, and snippets.

View paololeonardi's full-sized avatar

Paolo Leonardi paololeonardi

View GitHub Profile
@chriseidhof
chriseidhof / collectionview.swift
Last active January 31, 2024 19:00
SwiftUI Flow Layout
//
// ContentView.swift
// DeleteMe
//
// Created by Chris Eidhof on 02.02.21.
//
import SwiftUI
/*
@rnapier
rnapier / crusty.txt
Created February 3, 2016 16:12
Crusty Notes
# Beyond Crusty: Real-World Protocols
## Slide 1
Who here saw last WWDC's talk Protocol-Oriented Programming in Swift? The Crusty talk?
It is without a doubt the most important Swift talk. You have to watch it. It is probably the best talk I've ever seen at WWDC. And it's entire point is that subclassing is a needless complexity and that the right solution to most problems is protocols. Apple goes so far as to say that Swift is the first Protocol-Oriented Programming language.
Now, I take some exception to that. I don't think Swift is the first Protocol-Oriented Programming language. I think Go is much more "protocol-oriented" than Swift today, but that's a debate for beer later. Swift clearly is protocol-oriented, and that's great.
## Slide 2
@beccadax
beccadax / Example.swift
Last active December 30, 2025 18:15
Elegant handling of localizable strings in Swift. Note: This code is in Swift 2 and would need updates to be used in modern Swift.
let color = "blue"
let num = 42
localized("Colorless green ideas sleep furiously.")
localized("Colorless \(color) ideas sleep furiously.")
localized("\(num.formatted("%05d")) colorless green ideas sleep furiously.")
@jellybeansoup
jellybeansoup / update-version.sh
Last active June 23, 2021 08:44
Script for Incrementing Version Numbers
#!/bin/bash
# Link: <https://gist.github.com/jellybeansoup/db7b24fb4c7ed44030f4>
#
# A command-line script for incrementing build numbers for all known targets in an Xcode project.
#
# This script has two main goals: firstly, to ensure that all the targets in a project have the
# same CFBundleVersion and CFBundleShortVersionString values. This is because mismatched values
# can cause a warning when submitting to the App Store. Secondly, to ensure that the build number
# is incremented appropriately when git has changes.
#
@rbobbins
rbobbins / value_types.md
Created June 12, 2015 22:09
Build Better Apps with Value Types in Swift

Build Better Apps with Value Types in Swift

Agenda

  • Reference semantics
  • Immutability
  • Value semantics
  • Value types in practice
  • Mixing value types and reference types

Reference semantics

@rbobbins
rbobbins / protocols.md
Last active June 11, 2024 22:11
Notes from "Protocol-Oriented Programming in Swift"

PS: If you liked this talk or like this concept, let's chat about iOS development at Stitch Fix! #shamelessplug

Protocol-Oriented Programming in Swift

Speaker: David Abrahams. (Tech lead for Swift standard library)

  • "Crusty" is an old-school programmer who doesn't trust IDE's, debuggers, programming fads. He's cynical, grumpy.

  • OOP has been around since the 1970's. It's not actually new.

  • Classes are Awesome

    • Encapsulation
    • Access control
@blasten
blasten / gcd.swift
Created January 6, 2015 18:40
Managing threads in swift using Grand Central Dispatch
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)) {
// I'm the background thread
dispatch_async(dispatch_get_main_queue()) {
// I'm the UI thread
}
}