Michael Long
Apr 3, 2023

--

"where we have a reference to that object passed to us".

ObservedObject is not managing state. You can use OO with a passed parameter just as long as SOMEONE is keeping a hard reference to the object.

Look at ParentView2 in Question 2. The TestViewModel object is created on the fly and passed into TestView2. Which leads us to the problems discussed in the article. No one is maintaining a persistent reference to the VM.

Question 5 shows the traditional SO/OO passed pair.

--

--

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