2016-06-15 71 views
0

這樣便於非原子自定義設置強,複製,弱和分配與原子和非原子?

@property (copy, nonatomic) NSString *someString; 

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

喜歡這個副本的二傳手我想知道強,弱的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; 

回答

1

例:setter方法

- (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; 
} 
相關問題