Inside my app I retrieve URL's and I would like to present them but in a short way. I found this SO-Question for Objective-C
.
What is the easiest way to get this done in Swift?
Something like this should do it
let link = "https://google.com"
let url = URL(string: "https://tiny url.com/api-create.php?url=\(link)")!
let shortLink = try! String(contentsOf: url)
print(shortLink)
Note you’ll need to remove the space between tiny and url to make it work as SO complains when you post shortened URLs and it thinks that is a shortened one.
You’ll also not want to force unwrap either and handle the errors appropriately.