Lost Hours Integrating SwiftData
Debug vs. Release: When Code Only Crashes in Release extension ModelContext { func fetch<Model: PersistentModel & Identifiable<UUID>>(id: UUID) throws -> Model? { le...
Debug vs. Release: When Code Only Crashes in Release extension ModelContext { func fetch<Model: PersistentModel & Identifiable<UUID>>(id: UUID) throws -> Model? { le...
Integrating Firebase Realtime Database with Swift’s Codable protocol should be straightforward, but a few non-obvious behaviors can lead to hours of frustrating debugging. Here are three key pitfal...
When building user interfaces, it’s common to show or hide views based on state. In SwiftUI, there are several options: A simple if-else statement The .hidden() modifier The .opacity(_:) mo...
Use with caution: Avoid accessing MainActor synchronously unless absolutely necessary. In rare cases—particularly when integrating with legacy code—you may need to synchronously access MainActor-...
The fixedSize modifier in SwiftUI forces a view to adopt its ideal size, preventing it from being compressed or truncated. For example, you can use it to make sure a long text isn’t cut off: Text...
Recap WWDC20 Data Essentials in SwiftUI Views only exist transiently. After SwiftUI completes a rendering pass, the structs themselves go away. But because we marked this property as State, Sw...
TaskLocal is a mechanism within Swift’s concurrency system that allows you to store and access values that are local to a task and its child tasks. It’s similar to thread-local storage from the pre...
When writing Swift code, you may encounter situations where you need to represent a combination of options in a clean, efficient, and type-safe manner. This is where Swift’s OptionSet comes into pl...
SwiftUI allow us to pass data from parent to child views via environment. But what if you need to send data from child views back to their parent? This is where SwiftUI preference comes in. prefere...
SwiftUI’s sheet modifier is a fantastic tool, but it comes with limitations: it doesn’t automatically resize to fit its content. Apple introduced the .presentationSizing(.fitted) modifier in iOS 18...