I am calculate the escaping
and non-escaping
closures start and endtime inside the function. to see which function will end earlier.
func escapingexample (c: @escaping ()->Void){
print("escapingex body starts" + String(clock()))
c()
print("escapingex body ends" + String(clock()))
}
class testesc{
var x = 0;
var completionHandlers = [(String)->Void]()
func exampe(){
print("exampe " + String(clock()))
escapingexample {
self.x = 4
self.completionHandlers
print("escapingex closure " + String(clock()))
}
}
deinit {
print("deinit testesc")
}
}
var t_2 = testesc()
t_2.exampe();
but it looks that escaping closure not long living after calling function returns
escapingex body starts297900
escapingex closure 298193
escapingex body ends298265