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

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 the Binding instead.

String(meme.userid.wrappedValue)

This definitely couldn’t have worked in its current form until yesterday. You probably replaced the Int property with a Binding<Int> and that’s what introduced the issue.

Why is swift such a pile of garbage :/

It isn’t. You just made a mistake 🙂

Leave a Reply