本文介紹了用弧覆蓋設置器的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
限時送ChatGPT賬號..
@interface Article : NSObject
@property (nonatomic, strong) NSString *imageURLString;
@end
@implementation Class
@synthesize imageURLString = _imageURLString;
- (void)setImageURLString:(NSString *)imageURLString {
_imageURLString = imageURLString;
//do something else
}
啟用 ARC 時我是否正確覆蓋了設置器?
Did I correctly override the setter when ARC is enabled?
推薦答案
是的,這是正確的.我也花了一段時間才相信這確實是正確的做法.
Yes, this is correct. Also took me a while to trust that this is indeed the right thing to do.
您確實意識到,在這種情況下,覆蓋不是必需的,因為您不會做比標準生成的 setter 做的更多的事情嗎?僅當您向 setImageURLString:
添加更多代碼時,您才需要覆蓋 setter.
You do realize that in this case, the override is not necessary as you don't do more than the standard generated setter would do? Only if you add more code to setImageURLString:
would you need to override the setter.
這篇關于用弧覆蓋設置器的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!
【網(wǎng)站聲明】本站部分內容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯(lián)系我們刪除處理,感謝您的支持!