This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
TARGET="[email protected]"; APP="/path/to/DerivedData/.../MyApp.app"; APP_NAME=$(basename "$APP"); rsync -avE --delete "$APP" "$TARGET:/Applications/" && ssh "$TARGET" "echo Remote host: \$(hostname); codesign --force --deep -s - /Applications/$APP_NAME && open -n /Applications/$APP_NAME" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public extension Task where Success == Void , Failure == Never { | |
// Suspends until the task is cancelled | |
static func cancellation() async -> Void { | |
let s = AsyncStream<Void>{ continuation in } | |
for await _ in s { | |
} | |
} | |
// EMITS INFINITE ELEMENTS CPU 100% |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// EnvironmentDimmedTintColorViewModifier.swift | |
// Learn | |
// | |
// Created by Juan Arzola on 3/17/25. | |
// Copyright © 2025 Juan Arzola. All rights reserved. | |
// | |
import SwiftUI | |
import UIKit |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftData | |
extension PersistentIdentifier { | |
var shortDebugDescription: String { | |
let description = "\(self)" | |
let entityNameRange = description.firstMatch(of: self.entityName)?.range | |
let lastParenthesisRange = description.firstMatch(of: ")")?.range | |
if let entityNameRange, let lastParenthesisRange, | |
entityNameRange.lowerBound < lastParenthesisRange.upperBound { | |
return String(description[entityNameRange.lowerBound..<lastParenthesisRange.lowerBound]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension ModelContainer { | |
// non-throwing version | |
nonisolated func runNonisolated<ResultType, ActorType: InitWithModelContainer>( | |
action: @Sendable (_ actor: ActorType) async -> ResultType | |
) async -> ResultType { | |
let actor = ActorType(modelContainer: self) | |
let result = await action(actor) | |
return result | |
} | |
// throwing version |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Our one super simple SwiftData Model | |
@Model | |
class Item { | |
... | |
} | |
// MARK: - TodayView | |
@MainActor |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// MARK: - TodayView | |
@MainActor | |
struct TodayView: View { | |
@State private var viewModel = TodayViewModel() | |
@Environment(\.modelContext) private var modelContext | |
var body: some View { | |
HStack { | |
switch viewModel.content { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct ContentView: View { | |
var body: some View { | |
List { | |
SomeRow() | |
// set the background of the row | |
.listRowBackground(ListRowBackground()) | |
// .listRowSelectedBackground(ListRowSelectedBackground()) | |
// Oh no, `listRowSelectedBackground` above is not a real API, so list cells don't highlight when selected anymore. | |
// What do we do now? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// slow version | |
struct MyFancyList: View { | |
@Query(FetchDescriptors.fancyListItems) var items | |
var sections: [ListSection] = [] | |
var body: some View { | |
// it's a bad idea to build sections here, as that can execute for all sorts of updates to the view (there's more going on in this view in the original code) | |
SomethingRenderingSections(ListSection.sections(for: items, editMode: editMode, searchText: searchText) | |
.fullScreenCover(isPresented: $someFullScreenThingVisible) { SomethingThatCovers() } |
NewerOlder