I have this function
func calc1(){
var urll = [String]()
for var i = 0; i < restu_id.count; ++i{
var url = "https://maps.googleapis.com/maps/api/distancematrix/json?origins=\(lat[i]),\(long[i])&destinations=6.447768,3.48124859999996&mode=driving&language=pl-PLe"
urll.append(url)
}
for im in urll{
print(im)
rtu(im)
var delivP:Int?
let url = NSURL(string: im)
let task = NSURLSession.sharedSession().dataTaskWithURL(url!) {
(data, response, error) in
let jsonObj = JSON(data: data!)
let yy = jsonObj["rows"][0]["elements"][0]["distance"]["value"].int
var converted = (yy! / 1000) * 65
if converted < 400{
converted = 400
}
self.iu.append(converted)
print("IU:\(self.iu)")
}
task.resume()
}
}
When i print iu
in the closure it prints fine but when i try to use iu
to setup my cell in cellForRowAtIndexPath
i get nil
And am calling the calc1 function in viewdidload