What is a dangling pointer?

A dangling pointer is a pointer that points to invalid data or to data which is not valid anymore, for example: Class *object = new Class(); Class *object2 = object; delete object; object = nullptr; // now object2 points to something which is not valid anymore This can occur even in stack allocated objects: Object …

Read more

What is the difference between a weak reference and an unowned reference?

Both weak and unowned references do not create a strong hold on the referred object (a.k.a. they don’t increase the retain count in order to prevent ARC from deallocating the referred object). But why two keywords? This distinction has to do with the fact that Optional types are built-in the Swift language. Long story short …

Read more