nsscreencast / comments

Public comments on NSScreencast.com
0 stars 0 forks source link

Tip Calculator in SwiftUI #189

Open subdigital opened 3 years ago

subdigital commented 3 years ago

Written on 06/14/2019 20:34:25

URL: https://nsscreencast.com/episodes/397-swiftui-tip-calculator

subdigital commented 3 years ago

originally written by yoyohuba@gmail.com on 06/22/2019 06:21:53

Am I the only one to make this work in xcode11-beta2?

subdigital commented 3 years ago

originally written by yoyohuba@gmail.com on 06/22/2019 06:24:11

Sorry, typo, having trouble in beta2 to make it work... TextField is stalling and not updating the content<->static var

subdigital commented 3 years ago

originally written by subdigital on 06/25/2019 21:42:24

Looks like you found a bug with Beta 2. I see this issue as well, with TextFields that use formatters. I filed FB6243351 with Feedback Assistant in case you want to dupe it. As a workaround, you can omit the formatter part and using a string property as the backing @State var instead. You'll have to convert to a number before doing the tip math though.

subdigital commented 3 years ago

originally written by subdigital on 07/03/2019 15:31:11

Just a quick update. Beta 3 fixes this, but requires some additional code modifications to work. See the updated source code on Github.

subdigital commented 3 years ago

originally written by Freddy Hernandez on 08/09/2019 16:54:49

Is it possible that the problem you encountered around 13:40 was because of the fact that the closure passed to "ForEach" is expecting you to return a View and the return value is implicit if the closure only contains one line of code? Then another solution would have been to write "return Text(...)" at the end of the closure?