#import "ViewController.h"
@interface ViewController ()
@property (nonatomic, weak) UIView *weakView;
@property (nonatomic, weak) UIView *selfWeakView;
@property (nonatomic, strong) UIView *strongView;
@property (nonatomic, strong) UIView *selfStrongView;
@end
@implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
self.selfStrongView = [[UIView alloc]initWithFrame:CGRectMake(25, 25, 50, 50)];
printf("self.selfStrongViewretain count = %ld\n",CFGetRetainCount((__bridge CFTypeRef)(self.selfStrongView)));
[self.view addSubview:self.selfStrongView];
printf("self.selfStrongView retain count = %ld\n",CFGetRetainCount((__bridge CFTypeRef)(self.selfStrongView)));
_strongView = [[UIView alloc]initWithFrame:CGRectMake(100, 100, 50, 50)];
printf("_strongView retain count = %ld\n",CFGetRetainCount((__bridge CFTypeRef)(_strongView)));
[self.view addSubview:self.strongView];
printf("_strongView retain count = %ld\n",CFGetRetainCount((__bridge CFTypeRef)(_strongView)));
UIView *selfView = [[UIView alloc]initWithFrame:CGRectMake(150, 150, 50, 50)];
self.selfWeakView = selfView;
printf("self.selfWeakView retain count = %ld\n",CFGetRetainCount((__bridge CFTypeRef)(self.selfWeakView)));
[self.view addSubview:self.selfWeakView];
printf("self.selfWeakView retain count = %ld\n",CFGetRetainCount((__bridge CFTypeRef)(self.selfWeakView)));
UIView *weaksView = [[UIView alloc]initWithFrame:CGRectMake(200, 200, 50, 50)];
printf("weakView retain count = %ld\n",CFGetRetainCount((__bridge CFTypeRef)(weaksView)));
_weakView = weaksView;
printf("_weakView retain count = %ld\n",CFGetRetainCount((__bridge CFTypeRef)(_weakView)));
[self.view addSubview:_weakView];
printf("_weakView retain count = %ld\n",CFGetRetainCount((__bridge CFTypeRef)(_weakView)));
}
- (void)viewWillAppear:(BOOL)animated
{
printf("self.selfStrongView retain count = %ld\n",CFGetRetainCount((__bridge CFTypeRef)(_strongView)));
printf("_strongView retain count = %ld\n",CFGetRetainCount((__bridge CFTypeRef)(_strongView)));
printf("self.selfWeakView retain count = %ld\n",CFGetRetainCount((__bridge CFTypeRef)(self.selfWeakView)));
printf("_weakView retain count = %ld\n",CFGetRetainCount((__bridge CFTypeRef)(_weakView)));
}
@end