2. Swift uses ARC • ARC allocates memory for new instances. • ARC frees up memory when instance is no longer needed. • Tell ARC how are the relationships between your classes. • Accessing deallocated instances will crash your app :( • Deallocated = 0 reference counting
3. Assigning a class instance to variable, constant or property will make a strong reference. It will remain as long as you use it. Like using a leash (strong reference) with a dog, it can't run away!
5. Solution ! Define one of the references as "weak" or "unowned"
6. Weak *Doesn't keep strong reference to instance *Set to nil if the referenced instance is deallocated *Use it with delegate (Optional delegate)
7. Unowned *Doesn't keep strong reference to instance *Become dangling pointer(cause crash if accessed) when the referenced instance is deallocated *Assumed to always have a value *Same as "assign" in Objective-c
8. Strong Reference Cycle can also occur if you assign a closure to a property of a class instance, and the body of that closure captures the instance
9. Thanks References http://goo.gl/PJUX7f By Hossam Ghareeb