How do you fix a strong reference cycle? Use a weak reference. A weak reference is a pointer that does not imply ownership. To fix our strong reference cycle, an asset should not own its holder. Edit BNRAsset.h to make holder a weak reference:
#import <Foundation/Foundation.h> @class BNREmployee; @interface BNRAsset : NSObject @property (nonatomic, copy) NSString *label; @property (nonatomic, weak) BNREmployee *holder; @property (nonatomic) unsigned int resaleValue; @end
Build and run the program. Note that all the objects are now being deallocated correctly.
In a parent-child relationship, the general rule for preventing this type of strong reference cycle is the parent owns the child, but the child should not own the parent.