Skip to content

Instantly share code, notes, and snippets.

View cgoldsby's full-sized avatar

Chris Goldsby cgoldsby

View GitHub Profile
@cgoldsby
cgoldsby / SystemDeactivationMonitor.swift
Last active May 12, 2026 23:41
Tracks why the app became inactive: Control Center, App Switcher, Siri, etc.
//
// SystemDeactivationMonitor.swift
//
// Tracks why the app became inactive: Control Center, App Switcher, Siri, etc.
// Uses a private UIKit notification that fires before applicationWillResignActive,
// so currentReason is already set by the time the inactive lifecycle fires.
//
// Confirmed working on tvOS 26.4 and iOS 18.x.
//
// React Native usage:
@cgoldsby
cgoldsby / Suitest.podspec.json
Last active June 2, 2021 13:53
Suitest.podspec.json
{
"name": "Suitest",
"platforms": {
"tvos": "11.0",
"ios": "12.0"
},
"version": "1.5.0",
"summary": "Suitest is a test automation and device manipulation tool for AppleTV and iOS devices.",
"requires_arc": true,
"tvos": {
@cgoldsby
cgoldsby / psst.txt
Created March 28, 2019 11:24
psst! Down here!
┳┻|
┻┳|
┳┻| psst! Down here!
┻┳|
┳┻|
┻┳|
┳┻|
┻┳|
┳┻|
┻┳|
func myFunction() {
return _ = functionReturningString()
}
func functionReturningString() -> String {
return "Nothing to see here"
}
// Even works for a guard
func myFunction(value: Any?) {
func myFunction() {
return { print("All done") }() // Inline closure
}
func myFunction() {
return () // () -> Void
}
func myFunction() {
return Void() // Compiles!
func myFunction() {
defer { print("j/k... Now, I am done") }
return print("All done")
}
myFunction()
// Output:
// All done
// j/k... Now, I am done
func myFunction(value: Any?) {
guard let _ = value else { return valueIsNilDoSomething() }
valueIsNotNilDoSomethingElse()
}
func myFunction() {
return print("All done")
}
myFunction() // Output: All done
// MARK: - UIPopoverPresentationControllerDelegate
func adaptivePresentationStyle(for controller: UIPresentationController) -> UIModalPresentationStyle {
return .none
}