简体   繁体   中英

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM