Skip to content

Instantly share code, notes, and snippets.

View JoshHrach's full-sized avatar
🏠
Working from home

Josh Hrach JoshHrach

🏠
Working from home
View GitHub Profile
@JoshHrach
JoshHrach / DemoView.swift
Created January 16, 2024 00:48
UIViewRepresentable Sample Code
struct ThirdPartyDemoView: View {
@State private var shouldAdd = true
@State private var currentValue = 0
var body: some View {
ThirdPartyReader { proxy in
Text("\(currentValue)")
ThirdPartyView(shouldAdd: shouldAdd)
.viewChangedValueTo { view, newValue in
currentValue = newValue
@JoshHrach
JoshHrach / ContentView.swift
Created December 1, 2020 19:01
NavigationLink bug
struct ContentView: View {
var body: some View {
NavigationView {
List {
NavigationLink(destination: Text("Top Level")) {
Text("Top Level Link")
}
NavigationLink(destination: detailView) {
Text("Show Sub Links")
@JoshHrach
JoshHrach / gist:990b784b661de63485670cfda32a9e10
Last active April 28, 2020 23:56
Simple Binding example
struct NameDisplayView: View {
@State var name: String = "unknown"
@State var showNameChange = false
var body: some View {
VStack {
Text("Your name is \(name)")
Divider()
Button("Change") {
self.showNameChange = true
@JoshHrach
JoshHrach / PropertyWrappers.swift
Created April 9, 2020 01:14
Sample Property Wrappers
@propertyWrapper
/// Wrapper used to easily encode a `Date` to and decode a `Date` from an ISO 8601 formatted date string.
struct ISO8601Date: Codable {
var wrappedValue: Date
init(wrappedValue: Date) {
self.wrappedValue = wrappedValue
}
init(from decoder: Decoder) throws {
@JoshHrach
JoshHrach / fullsim
Created November 23, 2016 19:04 — forked from chrisfsampaio/fullsim
LLDB 'script' to enable full screen mode in the iOS Simulator
#!/usr/bin/env bash
lldb -n Simulator \
-o "expr ((NSWindow *)[(NSArray *)[[NSApplication sharedApplication] windows] setValue:@(1<<7|1<<8|1<<11) forKey:@\"collectionBehavior\"]);" \
-o "set set auto-confirm true" \
-o quit
call ((NSWindow *)[(NSArray *)[[NSApplication sharedApplication] windows] lastObject]).collectionBehavior = 1<<7|1<<8|1<<11
@JoshHrach
JoshHrach / gist:43738be7c848db1866fc25d9b95d93ba
Created August 1, 2016 18:47 — forked from eytanschulman/gist:8bd26bd6cd4d617868d99136253d95a6
Run Apps from Xcode 7.3.1 onto an iOS 10 device
sudo ln -s /Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport/10.0\ \(14A5322e\) \
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport