swiftui-numberfield icon indicating copy to clipboard operation
swiftui-numberfield copied to clipboard

Infinite Loop when used with @Published object

Open johnayers84 opened this issue 5 years ago • 3 comments

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.

johnayers84 avatar Mar 29 '20 19:03 johnayers84

Same issue for me. I thought I was going crazy because the example worked flawlessly. I'll need to dig into this more.

Danny-SS avatar Apr 18 '20 21:04 Danny-SS

Here's the fix:

https://stackoverflow.com/a/63305210/1135714

csr avatar Aug 07 '20 15:08 csr

Thanks a lot for letting me know about this conversation! I'll incorporate those changes.

edw avatar Aug 07 '20 15:08 edw