gpt4 book ai didi

ios - 强、复制、弱和分配原子和非原子的自定义 setter ?

转载 作者:行者123 更新时间:2023-11-29 00:53:46 28 4
gpt4 key购买 nike

就像这是非原子的 COPY 的 Setter

@property (copy, nonatomic) NSString *someString;

-(void)setSomeString:(NSString *)someString {
_someString = someString;
_someString = [someString copy];
}

像这样我想知道Strong、Weak和assign的setter和getter

@property (copy, atomic) NSString *someString; // Setter ?
@property (Strong, nonatomic) NSString *someString;
@property (assign, nonatomic) NSString *someString;
@property (Strong, atomic) NSString *someString;
@property (assign, atomic) NSString *someString;

最佳答案

例如:设置方法

- (void)setImgView:(UIImageView *)imgView{
if (_imgView == imgView) {
return;
}
_imgView = imgView;
_imgView.layer.borderColor = [UIColor clearColor].CGColor;
_imgView.layer.borderWidth = 0.0f;
_imgView.layer.cornerRadius = _imgView.frame.size.width/2;
}

关于ios - 强、复制、弱和分配原子和非原子的自定义 setter ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37825872/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com