Michael Long
Oct 13, 2022

--

I agree that the defaultValue singleton isn't optimal. Did you not see the "Yuck" that followed it, nor the actual solution using managed views?

Moving on, I also don't see the typo/wrong parameter objection as valid.

Pull the data from a classic view model and you have the same chance of a "typo" where the view grabs and displays the wrong value. Same from pulling it from some global state aka TCA. In either case you can test the view model or the pipeline all you want, but you're still not sure the view itself will render correctly.

The ultimate solution is, as suggested, a full UI integration test, but those tend to only target happy path behaviors as it can be difficult to run an app and trigger an edge case or error deep within the code.

--

--

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