Ambiguous use of appendInterpolation – Why?

Advertisements When using CustomStringConvertible structs, regular String interpolation works fine, however because Text (SwiftUI) uses LocalizedString interpolation, it doesn’t, and requires you to either fully append .description, or to use Text(verbatim: …) or Text(String(describing…)) Until(?) Apple harmonises the interpolation of String and LocalizedString, it seemed an easy enough fix to create an extension to make… Read More Ambiguous use of appendInterpolation – Why?

SwiftUI – Initializer 'init(_:)' requires that 'Binding<Int>' conform to 'LosslessStringConvertible'

Advertisements if(!user.hiddenUsersString.contains(String(meme.userid) + ",")){ } I get Initializer ‘init(_:)’ requires that ‘Binding<Int>’ conform to ‘LosslessStringConvertible’ on String what the hell is this? It worked without errors until yesterday. Why is swift such a pile of garbage :/ >Solution : You can’t pass a Binding to a String init. You need to pass the wrappedValue of… Read More SwiftUI – Initializer 'init(_:)' requires that 'Binding<Int>' conform to 'LosslessStringConvertible'

SwiftUI iOS16 Table with optional string as keypath

Advertisements How does one create a TableColumn for an optional property? Do i have to unwrap it in my model to make it an empty string if it is nil? extension SomeObject { var someOptionalStringUnwrapped: String { return someOptionalString ?? "" } } Table(someObject) { TableColumn("Given Name", value: \.someString) TableColumn("Given Name", value: \.someOptionalString) // <–shows error… Read More SwiftUI iOS16 Table with optional string as keypath

NavigationLink is only tappable on text section

Advertisements I have a NavigationLink: NavigationLink("Login") { WelcomeView() }.foregroundColor(.white).frame(width:300, height: 50).background(Color.blue).cornerRadius(10).padding().disabled(authenticateUser()) which looks like this: The issue is that the navigation only occurs when the user taps directly on the word "Login". If the user taps anywhere on the blue area outside of the text – no navigation occurs and nothing happens. How do I… Read More NavigationLink is only tappable on text section

In a view, how can I change the view's variables every time I press a button, using a struct's function?

Advertisements I have a problem while coding in content view. I don’t understand how can I use struct’s func in content view. I would like to get helps from you guys. I get an error like this "Result of call to ‘changeText(text:)’ is unused". Here’s simple example of what I’m trying to achieve, import Foundation… Read More In a view, how can I change the view's variables every time I press a button, using a struct's function?

SwiftUI losing reference while trying to reuse a UIViewRepresentable on different views

Advertisements I’m trying to reuse a UIKit view on SwiftUI with a UIViewRepresentable. Whenever i tap the representable i want to go to a fullScreenCover and reuse that same UIView. Somehow, when i close the fullscreenView, the UIView is missing. I’ve tried several approaches but i couldn’t make it work, Can some one point me… Read More SwiftUI losing reference while trying to reuse a UIViewRepresentable on different views

What's the meaning of .constant? Why not Boolean-literal?

Advertisements Can someone explain this syntax? static var previews: some View { Toast(isToastVisible: .constant(true)) } What’s .constant(true)? Especially: Why not Toast(isToastVisible: true)? >Solution : The isToastVisible property of your View is not a Boolean, it’s a Binding<Boolean>, which allows SwiftUI to observe when changes to your view happen, and update the UI as necessary. Bindings… Read More What's the meaning of .constant? Why not Boolean-literal?