How to rename the IBOutlet property without lose the connection

前端 未结 4 2032

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, nonatomi         


        
4条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-15 08:14

    Xcode 9, Refactor > Rename

    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...  

    1. Navigate to outlet in the header file

    @property (weak, nonatomic) IBOutlet UIButton *btnRequestCode;
    

     

    2. Right click on outlet, select "Refactor > Rename...".

     

    3. Change the outlet name

    4. Select the "Rename" button or the Enter key

     

    The outlet is renamed in the code and storyboard

    @property (weak, nonatomic) IBOutlet UIButton *requestCodeButton;
    

提交回复
热议问题