oscbyspro / DiffableTextViews

As-you-type formatting in SwiftUI
Apache License 2.0
56 stars 2 forks source link

SwiftUI vs Xcode 14.0 beta 5-6 #155

Closed oscbyspro closed 2 years ago

oscbyspro commented 2 years ago

In Xcode 14.0 beta 5, interpret(_:with:)’s output != input (autocorrection) yields:

Publishing changes from within view updates is not allowed, this will cause undefined behavior.

I’m unsure if it’s a bug or intentional, so I’ll wait and see if it persists in the next release.

oscbyspro commented 2 years ago

A) It’s intentional, because there’s a warning. B) It’s unintentional, because Xcode 14 beta 5 is an oven.


Xcode 14 beta 6 is a BBQ.

oscbyspro commented 2 years ago

I suppose what should be done about this depends on whether or not SwiftUI wants to support reentrancy. Async updates are not really an option because it would cause flutter (pun intended).

oscbyspro commented 2 years ago

If such updates are not allowed and/or supported, I suppose the most appropriate behavior is to disengage the view whenever it happens. Hm. I mean, that would be quite natural too, considering you kinda have to go out of your way to A) allow invalid values to be set from outside the view, and B) set the invalid value by simultaneously interacting with some other view (a button, for example).


Introduced dismiss mechanism in ac76804ad8d98cd573adb115d04a84419d38ad28.