Michael Long
May 6, 2021

--

It’s just a different mindset. You wouldn’t attempt to do “heavy lifting” in a UIKit draw method, or where doing so might block the main thread.

Again, the biggest problem I think most people have with SwiftUI is that views are not views (in the UIKit sense). SwiftUI view structures and view bodies exist simply to generate definitions of how the interface should appear, and SwiftUI asks for those definitions a lot.

Hence the limitations on where “heavy lifting” should occur.

The iDineNavigation sample code in the article shows one example where judicious use of onAppear can be used to trigger data loads in a SwiftUI-friendly manner.

--

--

Michael Long
Michael Long

Written by Michael Long

I write about Apple, Swift, and SwiftUI in particular, and technology in general. I'm also a Lead iOS Engineer at InRhythm, a modern digital consulting firm.

No responses yet