ios - Multiple NSURLSession to load Json -


i want load 2 nsurlsession. problem in second nsurlsession need key given first nsurlsession.

this did doesn't seem working !

nsurlsession.sharedsession().datataskwithurl(url!) { (data, response, error) in      {  let json = try nsjsonserialization.jsonobjectwithdata(data!, options: .mutablecontainers)  // fetching items json ...  item in items {    // extract id each item   let myid = item["id"] as! string   /* here problem want call nsurlsession     url contains myid (string) */     let url2 = nsurl(string:"http://example.com/something?id=\(myid)")  nsurlsession.sharedsession().datataskwithurl(url2!) { (data2, response2, error2) in      {     //the problem code not executed in each loop !         } catch let jsonerror2 {             print(jsonerror2)         }    }.resume()        }         } catch let jsonerror {             print(jsonerror)         }    }.resume() 

what should do?

for interested, solution keep code , add function sort data in array.


Comments