daily pastebin goal
51%
SHARE
TWEET

Untitled

a guest Dec 13th, 2018 85 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. {"data": [
  2. {"uid": 42423, "title": "Bares f\u00fcr Rares", "description": "Bei Horst Lichter und seinen Experten kann man Gegenst\u00e4nde aus der privaten Schatzkammer kompetent sch\u00e4tzen lassen. Dabei kommen oft spannende und kuriose Fakten und Geschichten ans Tageslicht. Sp\u00e4ter k\u00f6nnen die Gegenst\u00e4nde den vier H\u00e4ndlern zum Kauf angeboten werden. Der Meistbietende gewinnt.", "stop": "20181213150000", "start": "20181213143000", "channel": "zdf", "icon": "http://images.zattic.com/system/images/b3eb/1c76/3940/5332/0414/original.jpg"},
  3. {"uid": 42425, "title": "Keine Programminformationen verfuegbar", "description": "", "stop": "20181213151000", "start": "20181213150000", "channel": "zdf", "icon": "http://images.zattic.com/system/images/30e1/7100/cdb3/da61/4636/original.jpg"}
  4. ]}
  5.  
  6. Swift Playground:
  7.  
  8. import UIKit
  9. import Foundation
  10.  
  11. struct EPGList {
  12.     let data : EPGItem
  13. }
  14.  
  15. struct EPGItem: Decodable {
  16.     let item: Int
  17.     //let title : String
  18.     //let description : String
  19. }
  20.  
  21. func query(address: String) -> String {
  22.     let url = URL(string: address)
  23.     let semaphore = DispatchSemaphore(value: 0)
  24.    
  25.     var result: String = ""
  26.    
  27.     let task = URLSession.shared.dataTask(with: url!) {(data, response, error) in
  28.         result = String(data: data!, encoding: String.Encoding.utf8)!
  29.         semaphore.signal()
  30.     }
  31.    
  32.     task.resume()
  33.     semaphore.wait()
  34.     return result
  35. }
  36.  
  37. let result = query(address: "http://192.168.178.24:8080/?item=1&channel=zdf")
  38. let jsonData = result.data(using: .utf8)!
  39. let decoder = JSONDecoder()
  40. let EPG = try decoder.decode(EPGItem.self, from: jsonData)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top