iOS Code Review | Curated code improvement tips — Issue #21
iOS Code Review is a bi-weekly newsletter amplifying code improvement tips from the Apple developer community. Swift, Objective-C, iOS, macOS, SwiftUI, UIKit and more. Curated by Marina Gornostaeva and published every other Thursday.
Visit ioscodereview.com to subscribe to the newsletter or see older issues.
You can find even more tips on Twitter at @ios_code_review 🙌
Hi there,
Hope you’re safe, wherever you are. I’m excited to share this week’s findings with you!
This time I’m doing something new in addition to the usual tips. The pandemic has been hash on the conference scene, and the next conference season is coming up. I figured I’d highlight some conferences that are still looking for speakers.
Enjoy! ☀️
MainActor.run vs @MainActor
You can dispatch a Task
to the main actor two ways - by explicitly calling MainActor.run
or by annotating the closure with @MainActor
. These two ways have different behaviour. If already on the main thread, the former will run immediately but the latter will run on the next runloop cycle. Find detailed explanation in this article by Paul Hudson.