假设有一个类 名字叫做Puzzled继承UIViewController
声明了个属性 @property (nonatomic, strong) UIButton *btn;
跟声明了属性 @property (nonatomic, weak) UIButton *btn;
在- (void)viewDidLoad方法中调用 {
UIButton *btn = [[UIButton alloc]init];
self.btn = btn
}的区别是什么
大家讲道理2017-04-17 16:51:09
如果是有別的對象引用著他,就用weak,不然就用strong
如果沒有物件引用他,他創建完出了作用域,就會remove
還有就是當xib或storyboard中拖物過來的,那麼此時是用weak,