Sunday, November 8, 2026
HomeiOS Developmentios - Pressure view that conforms to protocol to have a property...

ios – Pressure view that conforms to protocol to have a property wrapper in SwiftUI

[ad_1]

I wish to implement sure Views to include a @Binding property thus I created a protocol for this.

Like the next:

protocol DismissableView: View {
   var isPresented: Binding<Bool> { get set }
}

And once I need my View to evolve to it, Like this:

struct MyView: DismissableView {
   @Binding var isPresented: Bool 
}

I get the next:

Sort 'MyView' doesn't conform to protocol 'DismissableView'

which I reckon is acquired to do with the truth that @Binding just isn’t the identical as Binding<Bool>

As you all are clearly conscious of the truth that I can not decalare a propertyWrapper in a protocol thus I’m unable to easily declare within the protocol a @Binding instantly, I’m fairly caught right here.

What am I to do.

T.I.A

[ad_2]

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments