dimanche 5 avril 2020

Swift - Opening another app in else statement

I would like to open Uber app from my app, when score number will be higher than 25. Here is my code:

        scoreLabel.text = "\(score)"


        if score <= 5
        { promilLabel.text = "Trzezwy"
        }
        else if score <= 10{
            promilLabel.text = "Wesoly"
        }
        else if score <= 15{
            promilLabel.text = "Pijany"
        }
        else if score <= 25{
             promilLabel.text = "Napierdolony"
        }
        else{
            promilLabel.text = "Wytrzezwialka"
        }
    }

I found sth like this, but how to add it to else statement?:

if let url = NSURL(string: "app://") where UIApplication.sharedApplication().canOpenURL(url) {
            UIApplication.sharedApplication().openURL(url)
} else if let itunesUrl = NSURL(string: "https://itunes.apple.com/itunes-link-to-app") where UIApplication.sharedApplication().canOpenURL(itunesUrl) {
            UIApplication.sharedApplication().openURL(itunesUrl)      
}

Aucun commentaire:

Enregistrer un commentaire