#import <Foundation/Foundation.h> /// 幾個對象互相引用,可能造成「保留環」 @class EOCClassA; @class EOCClassB; @interface EOCClassA : NSObject @property (nonatomic , strong) EOCClassB *other; @end @interface EOCClassB : NSObject @property (nonatomic , strong) EOCClassA *other; @end @interface EOCClassWeak : NSObject @property (nonatomic , weak) EOCClassA *otherA;//當實例回收後,weak屬性指向nil @property (nonatomic ,unsafe_unretained) EOCClassB *otherB;//仍然指向已回收的實例 @end #import "ViewController.h" @interface ViewController () @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } @end