I work with old project and in some part of the project, the naming convention is not good so I want to change it.
For example:
@property (weak, nonatomic) IBOutlet UIButton *btnRequestCode;
rename it to -> @property (weak, nonatomic) IBOutlet UIButton *requestCodeButton;
I know that I can delete the IBOutlet
then reconnect but it may take many time and easy make error if careless
Any safe and fast way to do it?
I have tried Refactor -> Rename but it doesn't work and give me an warning
Any help or suggestion would be great appreciated.
Select the view on the storyboard and then click the Connections Inspector. Then you can click the little x to remove an outlet reference.
@IBAction is similar to @IBOutlet , but goes the other way: @IBOutlet is a way of connecting code to storyboard layouts, and @IBAction is a way of making storyboard layouts trigger code. This method takes one parameter, called sender . It's of type UIButton because we know that's what will be calling the method.
The type qualifier IBOutlet is a tag applied to an property declaration so that the Interface Builder application can recognize the property as an outlet and synchronize the display and connection of it with Xcode. An outlet is declared as a weak reference ( weak ) to prevent strong reference cycles.
This is what I usually do
3.Replace to the name you want
4.You can click Replace All if you are sure. You can also to click preview to Replace every single change
New in Xcode 9 you can rename an outlet (or action) in the code and storyboard at the same time.
*DISCLAIMER: This feature only works in Xcode 9 (released September 2017) and above. Make sure to backup your project before using it. After making outlet name changes, test the affected screen(s) to make sure there are not issues. I tested this in a sample Objective C project successfully but it could cause problems in existing, more complex projects.
To rename an outlet...
@property (weak, nonatomic) IBOutlet UIButton *btnRequestCode;
@property (weak, nonatomic) IBOutlet UIButton *requestCodeButton;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With