You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to make a wordle app just to practice my coding skills. I wanted to know if its possible to get access to random words from the dictionary every-time I press a button. Is that possible? Thanks!
`func fetchDict(word: String) {
let baseURL = "https://api.dictionaryapi.dev/api/v2/entries/en/\(word)"
let url = URL(string: baseURL)
URLSession.shared.dataTask(with: url!) { data, response, error in
if let error = error {
print(error.localizedDescription)
} else {
if let data = data {
let jsonResponse = try? JSONSerialization.jsonObject(with: data, options: []) as? [[String: Any]]
jsonResponse!.forEach ({ element in
//get access to words from dictionary api
var wordList = SearchDictionary()
wordList.word = element["word"] as? String
DispatchQueue.main.async {
self.words.text = wordList.word
}
})
}
}
}.resume()
}
}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I want to make a wordle app just to practice my coding skills. I wanted to know if its possible to get access to random words from the dictionary every-time I press a button. Is that possible? Thanks!
`
Beta Was this translation helpful? Give feedback.
All reactions