Michael Long
1 min readJan 11, 2024

--

Makes the assertion, but where are the facts to back it up? Obviously complex view hierarchies require additional work, but is the amount of extra work actually prohibitive?

The struct advice is also somewhat problematic, as a struct with a lot of strings, arrays, and so forth still requires reference counting behind the scenes. Class allocation in the form of view models typically only occurs once as allocation is managed by StateObject.

The conditional logic advice shows code that won't work, since the preferred version would return views of different types. There are ways around it, but using ViewBuilder puts you back into the same place.

Limit the number of views??? Hardly. Apple has stated time and again that SwiftUI "views" are lightweight data structures and that one incurs little to no performance penalty for splitting views into subviews. See Apple's Demystifying SwiftUI WWDC talk.

I agree that it’s about understanding the intricacies of the language, the runtime, and the tools at your disposal... but I'm afraid that many of the recommendations made here fail to do so.

--

--

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