edudnyk / SheeKit

Customize and resize sheets in SwiftUI with SheeKit. Utilise the power of `UISheetPresentationController` and other UIKit features.
MIT License
91 stars 7 forks source link

Cannot convert value of type 'Binding<UISheetPresentationController.Detent.Identifier>' #5

Closed jtansley closed 2 years ago

jtansley commented 2 years ago

Hello,

Thank you for this useful Swift package! I'm trying to integrate this into my project but I'm getting the following error:

Screen Shot 2022-02-09 at 10 53 00 AM

Cannot convert value of type 'Binding<UISheetPresentationController.Detent.Identifier>' to expected argument type 'Binding<UISheetPresentationController.Detent.Identifier?>'

I have this variable set as follows: @State private var selectedDetentIdentifier = UISheetPresentationController.Detent.Identifier.medium

Thanks for your time

edudnyk commented 2 years ago

Hi @jtansley.

As the error mentions, the type of the identifier has to be optional. In your case, it infers non-optional type.

To make it optional, define it this way:

@State private var selectedDetentIdentifier: UISheetPresentationController.Detent.Identifier? = .medium
jtansley commented 2 years ago

That worked, thank you and thanks again for the quick response!