Search code examples
iosobjective-cxcoderefactoringgetter-setter

Xcode refactor doesn't rename setter and getter when I rename property name


Renaming property works only property name, but doesn't rename its getter and setter method.

For example, in the following code, when I rename propertyA to propertyB, self.propertyA = @"ccc" and return propertyA is renamed. But -(void)setPropertyA: and -(NSString *)propertyA is not renamed.

@property(nonatomic, strong) NSString *propertyA;

-(void)setPropertyA:(NSString *)propertyA
{
    self.propertyA = @"ccc";
}

-(NSString *)propertyA
{
    return propertyA;
}

It's very dangerous if I forget to manually rename getter and setter.

How to make Xcode rename getter and setter when I rename property?


Solution

  • I don't think you can. However, in the case above you don't need to. In the simple case you should just use @synthesize propertyA.

    The Xcode refactoring tools are unfortunately still in an early stage of development.