NSURLSession completion block not called

前端 未结 6 841
天命终不由人
天命终不由人 2021-02-18 19:07
var session = NSURLSession.sharedSession()
session.dataTaskWithRequest(urlRequest, 
                            completionHandler: {(data: NSData!, 
                             


        
6条回答
  •  北恋
    北恋 (楼主)
    2021-02-18 19:44

    You can also use it simply by :-

    let url = "api url"
    
    let nsURL = NSURL
    
    let task = NSURLSession.sharedSession().dataTaskWithURL(nsURL) {
    (data, response, error) in
       // your condition on success and failure
    }
    
    task.resume()
    

提交回复
热议问题