swiftui-numberfield
swiftui-numberfield copied to clipboard
Infinite Loop when used with @Published object
If I create a sample class:
class Sample: ObservedObject {
@Published var myDecimal: Decimal
@Published var someOtherVar: Bool
}
And Implement it like:
var myObject = Sample()
...
DecimalField("My Decimal", value: $myObject.myDecimal, formatter: Self.aFormatter)
The publisher and onRecieve methods go into a terminal loop that locks up the main thread and eventually crashes.
Same issue for me. I thought I was going crazy because the example worked flawlessly. I'll need to dig into this more.
Here's the fix:
https://stackoverflow.com/a/63305210/1135714
Thanks a lot for letting me know about this conversation! I'll incorporate those changes.