Skip to content

Instantly share code, notes, and snippets.

@MarcoEidinger
MarcoEidinger / findRequiredReasonAPIUsage.sh
Created August 21, 2023 19:55
A shell script to find if any "required reason API" are used in Swift or Objective-C files within that folder or subfolders
#!/bin/bash
# https://developer.apple.com/documentation/bundleresources/privacy_manifest_files/describing_use_of_required_reason_api
searchTerms=(
# File timestamp APIs
"creationDate"
"modificationDate"
"fileModificationDate"
"contentModificationDateKey"
"creationDateKey"
@brettohland
brettohland / 1.0 FormatStyle in Excruciating Detail.md
Last active October 14, 2025 22:59
FormatStyle in Excruciating Detail
@atierian
atierian / README.md
Last active July 30, 2025 03:41
Allow consumers of SwiftUI UIViewRepresentable conforming Views to inject wrapped UIView delegate implementations through ViewModifiers using a ProxyDelegate.

Allow the consumer of a SwiftUI UIViewRepresentable View to inject delegate implementations for the wrapped UIView through View Modifiers by using a proxy delegate.

This can be a helpful pattern when providing a SwiftUI wrapper for a very heavy and complex UIView, where the wrapper implements many of the delegate methods of the wrapped UIView. But you want someone consuming the wrapper to have the ability to inject their own delegate method implementations to override yours, or to leverage some of the methods your not implementing.

@atierian
atierian / MyCell.swift
Created October 28, 2021 14:43
Oversimplified Example of MVVM
class MyCell: UITableViewCell {
let titleLabel = UILabel()
let subtitleLabel = UILabel()
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
}
required init?(coder: NSCoder) { nil }
@atierian
atierian / StateMachines.swift
Created August 31, 2021 14:14
Building State Machines in Swift
/*
Cory Benfield - Building State Machines in Swift
https://www.youtube.com/watch?v=7UC7OUdtY_Q
What is a Finite State Machine?
- Structured way to represent computation
- System can be in one of a finite number of states at any time
- Reacts to inputs by changing state, and optionally producing a side effect
- Deterministic and nondeterministic flavors
- Simple model of computation: easy to understand
@jz709u
jz709u / Calendar.swift
Last active March 2, 2023 03:41 — forked from mecid/Calendar.swift
SwiftUI Calendar view using LazyVGrid
import SwiftUI
fileprivate extension DateFormatter {
static var month: DateFormatter {
let formatter = DateFormatter()
formatter.dateFormat = "MMMM"
return formatter
}
static var monthAndYear: DateFormatter {
//Orginal code from: https://gist.github.com/mecid/f8859ea4bdbd02cf5d440d58e936faec
//I just made some modification in appearnce, show monthly navigator and weekdays.
import SwiftUI
struct ContentView: View {
@Environment(\.calendar) var calendar
private var year: DateInterval {
calendar.dateInterval(of: .month, for: Date())!
@chriseidhof
chriseidhof / boilerplate.swift
Last active September 27, 2025 12:39
QuickMacApp
// Run any SwiftUI view as a Mac app.
import Cocoa
import SwiftUI
NSApplication.shared.run {
VStack {
Text("Hello, World")
.padding()
.background(Capsule().fill(Color.blue))