I'm trying to display a Text with different URLs in swiftUI but face an issue with string interpolation.
I used the instruction here to add a custom URL scheme to my test app and when I use a basic test URL it works:
Text("[\(text)](urlschemetest://action)")
.onOpenURL { link in
print("LINK: \(link)")
}
When I create the the same with a string interpolation within the URL part though the link doesn't work anymore.
Text("[\(text)](urlschemetest://\(actionVariable))")
.onOpenURL { link in
print("LINK: \(link)")
}
Is there a way to have string interpolation to work or to populate the URL dynamically from a variable?
I assume I'm missing something simple but could not find anything related to this issue with my searches.
The goal is to use an array of words and connect each to its own URL. I currently use reduce on the array to build the string:
arrayObj.reduce(Text(""), {
$0 + Text("[\($1.word)](baps://action/\($1.urlAction!)) ") + Text(" ")
} )