Dispatching to the Main thread with MainActor in Swift
Donny Wals Blog
by donnywals
2d ago
Swift 5.5 introduced loads of new concurrency related features. One of these features is the annotation that we can apply to classes, functions, and properties. In this post you’ll learn several techniques that you can use to dispatch your code to the main thread from within Swift Concurrency’s tasks or by applying the main actor annotation. If you’d like to take a deep dive into learning… Source ..read more
Visit website
How to use experimental Swift versions and features in Xcode?
Donny Wals Blog
by donnywals
6d ago
If you’re keen on reading about what’s new in Swift or learn about all the cool things that are coming up, you’re probably following several folks in the iOS community that keep track and tell you about all the new things. But what if you read about an upcoming Swift feature that you’d like to try out? Do you have to wait for it to become available in a new Xcode release? Sometimes the answer is… Source ..read more
Visit website
Actor reentrancy in Swift explained
Donny Wals Blog
by donnywals
1w ago
When you start learning about actors in Swift, you’ll find that explanations will always contain something along the lines of “Actors protect shared mutable state by making sure the actor only does one thing at a time”. As a single sentence summary of actors, this is great but it misses an important nuance. While it’s true that actors do only one thing at a time, they don’t always execute function… Source ..read more
Visit website
Iterating over websocket messages with async / await in Swift
Donny Wals Blog
by donnywals
1M ago
..read more
Visit website
Building an AsyncSequence with AsyncStream.makeStream
Donny Wals Blog
by donnywals
1M ago
A while ago I’ve published a post that explains how you can use AsyncStream to build your own asynchronous sequences in Swift Concurrency. Since writing that post, a new approach to creating AsyncStream objects has been introduced to allow for more convenience stream building. In this post, I’ll expand on what we’ve already covered in the previous post so that we don’t have to go over everything... Source ..read more
Visit website
Everything you need to know about Swift 5.10
Donny Wals Blog
by donnywals
1M ago
The long awaited iOS 17.4 and iPadOS 17.4 have just been released which means that we could slowly but surely start seeing alternative app stores to appear if you’re an EU iOS user. Alongside the 17.4 releases Apple has made Xcode 15.3 and Swift 5.10 available. There’s not a huge number of proposals included in Swift 5.10 but that doesn’t make this release less significant. With Swift 5.10... Source ..read more
Visit website
Working with dates and Codable in Swift
Donny Wals Blog
by donnywals
1M ago
When you’re decoding JSON, you’ll run into situations where you’ll have to decode dates every once in a while. Most commonly you’ll probably be dealing with dates that conform to the ISO-8601 standard but there’s also a good chance that you’ll have to deal with different date formats. In this post, we’ll take a look at how you can leverage some of Swift’s built-in date formats for en- and decoding... Source ..read more
Visit website
Designing APIs with typed throws in Swift
Donny Wals Blog
by donnywals
2M ago
When Swift 2.0 added the keyword to the language, folks were somewhat divided on its usefulness. Some people preferred designing their APIs with an (at the time) unofficial implementation of the type because that worked with both regular and callback based functions. However, the language feature got adopted and a new complaint came up regularly. The way in Swift was designed didn’t allow... Source ..read more
Visit website
How to determine where tasks and async functions run in Swift?
Donny Wals Blog
by donnywals
2M ago
Swift’s current concurrency model leverages tasks to encapsulate the asynchronous work that you’d like to perform. I wrote about the different kinds of tasks we have in Swift in the past. You can take a look at that post here. In this post, I’d like to explore the rules that Swift applies when it determines where your tasks and functions run. More specifically, I’d like to explore how we can... Source ..read more
Visit website
Comparing @Observable to ObservableObjects
Donny Wals Blog
by donnywals
2M ago
With iOS 17, we’ve gained a new way to provide observable data to our SwiftUI views. Until iOS 17, we’d use either an with , , or whenever we had a reference type that we wanted to observe in one of our SwiftUI views. For lots of apps this worked absolutely fine, but these objects have a dependency on the Combine framework (which in my opinion isn’t a big deal), and they made it really hard for... Source ..read more
Visit website

Follow Donny Wals Blog on FeedSpot

Continue with Google
Continue with Apple
OR