HomeiOS Developmentios - JSON knowledge extraction with Swift

ios – JSON knowledge extraction with Swift


Hey i wish to knowledge extraction however How can I extraction the worth of every foreign money individually ?

JSON

`let url = URL(string: “https://api.currencyapi.com/v3/newest?apikey=11111blabla”)

    let session = URLSession.shared
    
    let activity = session.dataTask(with: url!) { knowledge, response, error in
        if error != nil {
            let alert = UIAlertController(title: "Error", message: error?.localizedDescription, preferredStyle: UIAlertController.Type.alert)
            let okButton = UIAlertAction(title: "Oke", type: UIAlertAction.Type.default)
            alert.addAction(okButton)
            
            self.current(alert, animated: true)
        }else{
            
            if knowledge != nil {
                do {
                    let jsonResponse = attempt JSONSerialization.jsonObject(with: knowledge!, choices: JSONSerialization.ReadingOptions.mutableContainers) as! Dictionary<String, Any>
                    
                    DispatchQueue.essential.async {
                        if let charges = jsonResponse["code"] as? [String : Any]{
                          //  print(charges)
                            if let eur = charges["EUR"] as? Double{
                                print(eur)
                            }
                        }
                    }
                } catch{
                    print("Error")
                }
                
            }
        }
        
        
        
    }
    activity.resume()
}

}`

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments