Skip to content

Instantly share code, notes, and snippets.

View benrudhart's full-sized avatar

Ben Rudhart benrudhart

View GitHub Profile
@benrudhart
benrudhart / AsyncModelActor.swift
Last active July 5, 2024 15:39
AsyncModelActor.swift
import Foundation
import SwiftData
/// The `AsyncModelActor` protocol leverages SwiftData's `@ModelActor` to safely and concurrently perform operations (CRUD) on different threads.
///
/// ### Problem:
/// By default, all `ModelActor` instances execute tasks on the thread they were initialized on. This means that if a `@ModelActor` is initialized on the main thread
/// (e.g., in a SwiftUI View or ViewModel), all its operations will run on the main thread, potentially leading to performance issues.
///
/// ### Solution:
@benrudhart
benrudhart / AppearanceInvocations.md
Last active July 13, 2016 12:48
UIViewController appearance method invocations when using swipe to get back in a UINavigationController

When starting to swipe

  • From WillDisAppear
  • To WillAppear

When swipe finished

  • From DidDisAppear
  • To DidAppear
@benrudhart
benrudhart / AssociatedProtocol
Created May 27, 2015 12:38
A Swift protocol that is using an enum with a generic associated type
import Foundation
import UIKit
//: # The problem: Protocol that is using an enum with generic associated type
enum GenericEnum<T> {
case Unassociated
case Associated(T)
}
@benrudhart
benrudhart / Dumping
Created March 5, 2015 07:53
dumping of NSView & subviews
// Dumping.swift
//
// Copyright (c) 2015 Ben Rudhart | www.app-grade.de
// This class is ported from an objectiv-c version found here: http://www.blackdogfoundry.com/blog/common-xcode4-plugin-techniques/
import Foundation
import AppKit
extension NSView {
@benrudhart
benrudhart / gist:1525c82fea925c985b90
Last active August 29, 2015 14:09 — forked from shiningabdul/gist:8634264
Script for Uploading an xcode archive to HockeyApp with Xcode Server 4.0 using Xcode 6.1. Automatically creates a markdown change log based on the commit bodies from accepted pull requests.
# Valid and working as of 11/10/2014
# Xcode 6.1, XCode Server 4.0
#Upload Archive to HockeyApp
#Settings
PRODUCT_NAME="<Product name>"
PRODUCT_FOLDER="<Product Folder>"
SIGNING_IDENTITY="<identity>"
#"This has to be exactly what you see in Keychain -> My Certificates"