Michael Long
Apr 17, 2024

--

Second example is problematic in that you shouldn't be storing the functions that produce the views, but the actual views themselves.

Several reasons for this, but they all boil down to the facts that views are structs and diff'able, while closures and their captured state are not.

Doing the above can lead to state loss and subview update issues. Best avoided.

--

--

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.

Responses (1)