By letting ARC do its thing, you can pretty much sit back and relax as ARC allocates and deallocates memory when it is needed. However, there are situations when Rose really never lets go—when you create a permanent bond between two classes. Consider the new
Driver classes. Notice that when you create a new
Driver and new
Car, your driver’s car will be
nil and your car’s driver will be
nil. You can see what I mean when I create a new car and driver:
var car = Car(name: "Ford")var driver = Driver()
Now you have a new
car and new
driver that ARC has reference counted.
driver has a
car that is
nil, and car has a driver that is
nil. Now you can assign
car.driver = driver ...