How to use NSURLConnection completionHandler with swift

前端 未结 4 1994
感动是毒
感动是毒 2020-12-25 14:33

Does anybody know how handlers (blocks) work in swift? I am trying to get this code running but i can\'t find any documentation of the right syntax for the completionHandler

4条回答
  •  悲&欢浪女
    2020-12-25 15:09

    You need to use this code:

    NSURLConnection.sendAsynchronousRequest(request,queue:queue,completionHandler:{response,data,error in /* code goes here */ })
    

    For more info, you can refer to this tutorial, or or check the answers to How to parse a JSON file in swift?.

提交回复
热议问题