I want to declare a protocol that has function which must return NavigationLink. But when I try this it returns an error "Reference to generic type 'NavigationLink' requires arguments in <...>"
protocol Protocol: class{
func function() -> NavigationLink
}
(Jessy)
class BeersListRouter: BeersListRouterProtocol{
typealias Label = Text
typealias Destination = View
func getBeerDetailsView(for beer: Beer) -> NavigationLink<Label, Destination>{
}
}
CodePudding user response:
NavigationLink is a generic type, with two placeholders. You need to account for them.
protocol Protocol: AnyObject {
associatedtype Label: View
associatedtype Destination: View
func function() -> NavigationLink<Label, Destination>
}