2

I am grabbing the URL from a struct and sending it to a UITapGesture, and I tried printing it(it prints URL), but it doesn't want to actually open the URL.

@objc func getUrl(sender: UITapGestureRecognizer){
    guard  let url = self.rssUrl else { return }
    print(url)
    UIApplication.shared.open(url, options: [:], completionHandler: nil)
}

Grabbing an URL here

var rssUrl: URL?

var item: RSSItem! {
    DispatchQueue.global(qos: .userInteractive).async {
        //other code

        let store_Article = Article(dict: ["text": sum, "rssUrl": rssLink])
        storedArticle.append(store_Article)

        let data = dataUrl.init(articleUrl: store_Article).someUrl

        DispatchQueue.main.sync {
            //other code
        }
    }
}

Edit

it prints: http:/www.instyle.com/news/rihanna-30th-birthday-party -- file:///

for an example

1 Answers1

0

Try with this EDIT

@objc func getUrl(sender: UITapGestureRecognizer)
{
    guard let url = URL(string: YOUR_URL_STRING) else {
        return //be safe
    }

    if #available(iOS 10.0, *) {
        UIApplication.shared.open(url, options: [:], completionHandler: nil)
    } else {
        UIApplication.shared.openURL(url)
    }
}
Kamlesh Shingarakhiya
  • 2,757
  • 2
  • 16
  • 34