Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- func checkDeviceRegistry() -> Bool {
- var found: Bool = false
- let url = URL(string: "http://10.51.200.249:3000/api/devices")
- let task = URLSession.shared.dataTask(with: url!) { (data, response, error) in
- if let data = data {
- do {
- // Convert the data to JSON
- let jsonSerialized = try JSONSerialization.jsonObject(with: data, options: []) as? [String : Any]
- if let json = jsonSerialized, let url = json["url"], let explanation = json["explanation"] {
- // print(url)
- // print(explanation)
- print(json)
- }
- } catch let error as NSError {
- print(error.localizedDescription)
- }
- } else if let error = error {
- print(error.localizedDescription)
- }
- }
- task.resume()
- return found
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement