Search code examples
iphoneipadios5automatic-ref-counting

Override setter with arc


@interface Article : NSObject 

@property (nonatomic, strong) NSString *imageURLString;

@end


@implementation Class

@synthesize imageURLString = _imageURLString;

- (void)setImageURLString:(NSString *)imageURLString {
    _imageURLString = imageURLString;
    //do something else
}

Did I correctly override the setter when ARC is enabled?


Solution

  • Yes, this is correct. Also took me a while to trust that this is indeed the right thing to do.

    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.