Skip to content

Instantly share code, notes, and snippets.

Avatar
😷
status messages are fun

Rob Mayoff mayoff

😷
status messages are fun
View GitHub Profile
View iOS13_onChange.swift
import SwiftUI
import Combine
public struct ChangeObserver<V: Equatable>: ViewModifier {
public init(newValue: V, action: @escaping (V) -> Void) {
self.newValue = newValue
self.newAction = action
}
private typealias Action = (V) -> Void
View Class Clusters
As of iOS 11/macOS High Sierra, and only including ones in Foundation and CoreFoundation
Strings:
_NSCFString - a CFStringRef or CFMutableStringRef. This is the most common type of string object currently.
- May have 8 bit (ASCII) or 16 bit (UTF-16) backing store
_NSCFConstantString - a compile time constant CFStringRef, like you'd get with @"foo"
- May also be generated by dynamic string creation if matches a string in a pre-baked table of common strings called the StringROM
NSBigMutableString - an NSString backed by a CFStorage (https://github.com/opensource-apple/CF/blob/master/CFStorage.h) for faster handling of very large strings
NSCheapMutableString - a very limited NSMutableString that allows for zero-copy initialization. Used in NSFileManager for temporarily wrapping stack buffers.
@nubbel
nubbel / xcbuild-debugging-tricks.md
Created Jun 9, 2017 — forked from ddunbar/xcbuild-debugging-tricks.md
Xcode new build system debugging tricks
View xcbuild-debugging-tricks.md

New Build System Tricks

Command Line

# enable internal menu
defaults write com.apple.dt.Xcode ShowDVTDebugMenu -book YES

alias xcbuild=$(xcode-select -p)/../SharedFrameworks/XCBuild.framework/Versions/A/Support/xcbuild
@inamiy
inamiy / SwiftElmFrameworkList.md
Last active Apr 30, 2021
React & Elm inspired frameworks in Swift
View SwiftElmFrameworkList.md
@romaonthego
romaonthego / NSDateFormatter cheat sheet
Last active Apr 13, 2021
Date Formats for NSDateFormatter
View NSDateFormatter cheat sheet
a: AM/PM
A: 0~86399999 (Millisecond of Day)
c/cc: 1~7 (Day of Week)
ccc: Sun/Mon/Tue/Wed/Thu/Fri/Sat
cccc: Sunday/Monday/Tuesday/Wednesday/Thursday/Friday/Saturday
d: 1~31 (0 padded Day of Month)
D: 1~366 (0 padded Day of Year)
@stefanschmidt
stefanschmidt / silence-dropbox.sh
Created Aug 27, 2013
Stop Dropbox from asking for admin password after installation to ~/Applications
View silence-dropbox.sh
chmod 0000 ~/Applications/Dropbox.app/Contents/Resources/*.tgz
@chockenberry
chockenberry / finder_icons.sh
Last active Oct 22, 2020
A simple shell script to turn the Finders desktop icons on and off
View finder_icons.sh
#!/bin/sh
defaults read com.apple.finder CreateDesktop > /dev/null 2>&1
enabled=$?
if [ "$1" = "off" ]; then
if [ $enabled -eq 1 ]; then
defaults write com.apple.finder CreateDesktop false
osascript -e 'tell application "Finder" to quit'
open -a Finder
@dabrahams
dabrahams / FactoryInitialization.swift
Last active Sep 3, 2020
Class factory initializers
View FactoryInitialization.swift
/// Classes whose initializers actually create derived classes
protocol FactoryInitializable {
/// The type of the least-derived class declared to be FactoryInitializable.
///
/// - Warning: Do not define this in your FactoryInitializable type!
associatedtype FactoryBase: AnyObject, FactoryInitializable = Self
// This associatedtype is a trick that captures `Self` at the point where
// `FactoryInitializable` enters a class hierarchy; in other contexts, `Self`
// refers to the most-derived type.
}
View ContentView.swift
//
// ContentView.swift
// Layout
//
// Created by Matt Gallagher on 7/6/19.
// Copyright © 2019 Matt Gallagher. All rights reserved.
//
import SwiftUI
@jtbandes
jtbandes / ConstraintCollection.swift
Created Feb 20, 2015
Autolayout constraint literals in Swift
View ConstraintCollection.swift
#if os(iOS)
import UIKit
#else
import AppKit
#endif
/// A set of constraints prepared from a visual format string, in the style of
/// `NSLayoutConstraint.constraintsWithVisualFormat()`, with the additional ability
/// to supply views and metrics in a string interpolation.
///