https://fuckingapproachableswiftconcurrency.com/en/
#ycombinator #Swift #concurrency #async #await #actors #Sendable #MainActor #iOS #macOS #Swift_6 #tutorial #guide
I got buried in #concurrency and had to stop. 😅
The goal was to avoid using the `nonisolated` keyword in the context where #MainActor is the default isolation, but so far, I haven't found a better solution. 🤔
Here is the first response from the completed request! 🎉
It's taking longer than I thought, but I want to implement strict concurrency responsibly. 🕒🧐
At some points, it works with a project that has default isolation set on #MainActor. This is a default setting for #Xcode26, so I have to follow this rule. 🚀
So it begins... 🌟
Until now, the package had #MainActor default isolation. This was intentional to gain a clear understanding of where the #Sendable declaration is necessary.
Now, it's time to make this package truly thread-safe! 🚀
How do you bridge the gap between legacy Apple APIs and Swift 6's strict concurrency model?
𝑀𝑎𝑖𝑛𝐴𝑐𝑡𝑜𝑟.𝑎𝑠𝑠𝑢𝑚𝑒𝐼𝑠𝑜𝑙𝑎𝑡𝑒𝑑 provides a MainActor context within synchronous methods, solving compatibility issues with APIs like 𝑁𝑆𝑇𝑒𝑥𝑡𝐴𝑡𝑡𝑎𝑐ℎ𝑚𝑒𝑛𝑡𝑉𝑖𝑒𝑤𝑃𝑟𝑜𝑣𝑖𝑑𝑒𝑟 and 𝑈𝐼𝐻𝑜𝑠𝑡𝑖𝑛𝑔𝐶𝑜𝑛𝑡𝑟𝑜𝑙𝑙𝑒𝑟. This is essential knowledge for Swift 6 migration!
🔗: https://fatbobman.com/en/posts/mainactor-assumeisolated/ by @fatbobman
Previous problems with Swift Concurrency, in my opinion, stemmed from originally overlooking this crucial assumption. 💭
Now we can set that Default Actor Isolation will rely on #MainActor. This means our entire app will work on the main thread by default. ✨
2/5
Изоляция с помощью глобальных акторов в Swift Concurrency: варианты на примере @MainActor
Привет, Хабр! Меня зовут Алексей Григорьев, я техлид iOS-разработки продукта Membrana в МТС. Это тариф с приложением для управления приватностью в сети и окружением. Swift Concurrency принесла множество инструментов для управления многопоточностью. Среди них глобальные акторы, которые помогают обеспечивать безопасность данных и контролировать потоки выполнения. Один из самых распространенных и полезных глобальных акторов — это @MainActor, который гарантирует выполнение операций в главном потоке приложения. В этом посте я на его примере покажу все варианты, как можно реализовать изоляцию и что в итоге выведет код: на каком потоке будут выполнены update, internal update и set в property.
https://habr.com/ru/companies/ru_mts/articles/904378/
#mainactor #swift_concurrency #Глобальная_изоляция #разработка_мобильных_приложений #разработка_под_ios #swift #программирование