Post

Replies

Boosts

Views

Activity

Reply to Help Understanding Concurrency Error with Protocol Listener and Actor
I'm not a fan of annotating everything with @MainActor. So yes, in the case of Sendable, the newValue must also conform to Sendable. I’ve written Objective-C and pre-Swift 6 code for decades that just assumed that it was. How many weird crashes has that code caused over the years? Yeah, I totally get the value of having the compiler catch these things, it's a solid direction. Personally, I can't say I've run into that many crashes from threading issues in practice, at least judging by crash metrics, things have been pretty stable. I just find it hard to get excited about spending too much time fixing compiler errors :)
Topic: Programming Languages SubTopic: Swift Tags:
Apr ’25
Reply to SwiftUI crash: Simultaneous accesses to X, but modification requires exclusive access.
I've prepared a demo to reproduce the crash. I don't know how to attach it directly, so here's a dropbox link: https://www.dropbox.com/scl/fi/s4x49bykhjrnh7yxybajn/swiftui_toolbar_crash_example.zip?rlkey=d6iquywpvb8y3j0sshj6kjvh3&dl=0. You should press: "Click Me", then again "Click me" and then "Reset".
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Sep ’23
Reply to Help Understanding Concurrency Error with Protocol Listener and Actor
Hello, Thanks for your reply! Yeah, I’ve already figured that part out, but there’s one more issue: the value also needs to be sendable. I picked the simplest example, but this new concurrency model adds even more boilerplate code. Honestly, I’m finding this more challenging than working with ObjC back in 2009 🙂
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Apr ’25
Reply to Help Understanding Concurrency Error with Protocol Listener and Actor
I'm not a fan of annotating everything with @MainActor. So yes, in the case of Sendable, the newValue must also conform to Sendable. I’ve written Objective-C and pre-Swift 6 code for decades that just assumed that it was. How many weird crashes has that code caused over the years? Yeah, I totally get the value of having the compiler catch these things, it's a solid direction. Personally, I can't say I've run into that many crashes from threading issues in practice, at least judging by crash metrics, things have been pretty stable. I just find it hard to get excited about spending too much time fixing compiler errors :)
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Apr ’25