Advertisement
moviles_ccm

petición asíncrona

Jan 22nd, 2017
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Swift 0.49 KB | None | 0 0
  1.     func asincrono() {
  2.         let urls = "https://www.google.com.mx"
  3.         let url = URL(string: urls)
  4.         let sesion = URLSession.shared
  5.        
  6.         let bloque = { (datos: Data?, resp : URLResponse?, error : Error?) -> Void in
  7.             let texto = String(data: datos!, encoding: String.Encoding.isoLatin1)
  8.             print(texto!)
  9.         }
  10.         let dt = sesion.dataTask(with: url!, completionHandler: bloque)
  11.         dt.resume()
  12.         print("antes o después?")
  13.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement