假设有一个类 名字叫做Puzzled继承UIViewController 声明了个属性 @property (nonatomic, strong) UIButton *btn;
跟声明了属性 @property (nonatomic, weak) UIButton *btn; 在- (void)viewDidLoad方法中调用 {UIButton *btn = [[UIButton alloc]init];self.btn = btn}的区别是什么
欢迎选择我的课程,让我们一起见证您的进步~~
Since the generated button has no reference elsewhere, the property of the weak attribute will be lost after you assign the value.
If there are other objects referencing it, use weak, otherwise use strong
If no object refers to it and it is created out of scope, it will be removed
Also, when dragging objects from xib or storyboard, then use weak at this time,
Since the generated button has no reference elsewhere, the property of the weak attribute will be lost after you assign the value.
If there are other objects referencing it, use weak, otherwise use strong
If no object refers to it and it is created out of scope, it will be removed
Also, when dragging objects from xib or storyboard, then use weak at this time,