Skip to content

Instantly share code, notes, and snippets.

@hasanalisiseci
Last active March 1, 2020 15:34
Show Gist options
  • Save hasanalisiseci/9c53bf08604d2fb5da926e57c3064d6e to your computer and use it in GitHub Desktop.
Save hasanalisiseci/9c53bf08604d2fb5da926e57c3064d6e to your computer and use it in GitHub Desktop.
func getLyric() {
// Hedef URL'yi tanımlıyoruz
let url = URL(string: "https://api.kanye.rest/?format=text")
do {
//URL ile ulaştığımız veriyi String olarak alıyoruz.
let contents = try String(contentsOf: url!)
//String değeri text view'a gönderiyoruz.
textView.text = "\"\(contents)\""
} catch {
// İçerik yüklenemez ise
textView.text = "Could not load"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment