-2

I'm trying to use a Link in a SwiftUI view, and like every tutorial online, I'd like to use this one:

Link(destination: URL, label: () -> View)

It pops up as one of the autocomplete options, but as soon as I add it to my code, I get these three errors:

Extra arguments at positions #1, #2 in call

Missing arguments for parameters 'rel', 'href', 'method' in call

Static method 'buildExpression' requires that 'Link' conform to 'View'

It looks like Xcode wants to force me to use this Link instead:

Link(rel: String, href: String, method: String)

but I don't understand why Xcode won't let me use the first one. Does anyone know why this is happening? Is there something I need to import to get this to work?

I've tried removing the Link and re-adding it, as well as restarting Xcode.

jnpdx
  • 45,847
  • 6
  • 64
  • 94
kbartlett
  • 1
  • 1
  • 1
    The initializer you show is valid, but you'd need to show the actual code you used to determine what's wrong. Can you provide a [mre]? – jnpdx Aug 14 '23 at 17:06
  • There was a custom Link struct in the app - using SwiftUI.Link fixed the problem, as it did in the linked question. – kbartlett Aug 14 '23 at 18:26

0 Answers0