Advanced Swift: Memory Management · Breaking Cycles | raywenderlich.com


This is a companion discussion topic for the original entry at https://www.raywenderlich.com/1940727-advanced-swift-memory-management/lessons/7

Hi, I don’t get a fatal error like you in the video with this scope:

do {
let galileo = Supernova(“Galileo”)
DispatchQueue.global().asyncAfter(deadline: .now() + 0.1 ) { [ unowned galileo] in
galileo.explode()
print(galileo.name)
}
}

Even if I delay with 1 sec. Can you explain to me why? Thanks!

It just doesn’t print the new name.

@jfl111 Do you still have issues with this?

Hi Ray
Thank you for the tutorial. I have a question though.

The same code doesn’t cause a crash on my machine rather it opts to not print the ‘name’. What could be the reason for this different behavior?

They are always tweaking the behavior of playgrounds which causes the results to subtly change. If you make a iOS project and run it in viewDidLoad() I suspect you will get the behavior described.