Capturing ‘async let’ variables is not supported
Discovered this strange error in Swift, when using the sample code from the proposal which is supposed to have been accepted and implemented
Discovered this strange error in Swift, when using the sample code from the proposal which is supposed to have been accepted and implemented
I needed to show an alert in an async context and this is how I achieved it: The idea to throw a cancellation exception was inspired by DDDevicePickerViewController which is the only built-in async UIViewController I’m aware of.
I wondered why NSPersistentStoreRemoteChange doesn’t contain any info about what process made the change. For example it isn’t possible to know if the change even was made by the current process or not. This would be useful so when you make a save you know if you can skip reloading Read more
I came across this interesting Stack Overflow question How can I make a simple circular button in SwiftUI in macOS? It’s interesting because all of the proposed solutions required hard-coding a frame size. I decided to experiment with how to make a circle that dynamically resizes to the size of Read more
First visit the Apple Events web page and find the link to the stream you want to download, e.g. the link for the iPhone 14 event from September 2022 looks like this: Now you need to install the yt-dlp command line utility, in Terminal type: yt-dlp is a fork of Read more
Update 10/4/2024: It appears in Xcode 15.3 nothing special is required and can use await right next to the hello world print. TLDR: add @main and rename main.swift To create a command line tool in Xcode 14.3 that uses async/await there are a few tweaks required. When we create the Read more
Learning SwiftUI can be tricky because it has a very different design to previous UI frameworks. Many make the mistake of trying to apply old design patterns which are not really compatible because of SwiftUI’s use of value semantics and its diffing algorithm – most developers from UIKit, Java or Read more
Seems to me some developers think that @MainActor means “always main thread” and has the same behaviour as DispatchQueue.main.async which I don’t think is try. For example, the code below outputs: Because the Database class is not marked as @MainActor then loadModel will in fact be on a background thread, Read more
I came across an interesting Stack Overflow question about how to support List selection of different types when using NavigationSplitView when in regular width, e.g. on iPad landscape. This problem doesn’t arise with NavigationStackView because multiple ForEach can simply iterate an array of each value and then there is a Read more
If you need to show multiple sheets in SwiftUI it is best to use the framework features to your advantage. Rather than try to abstract the problem into a generic coordinator object, which you then have to unbundle again to customise each circumstance, you can simply create multiple small subview Read more