Modify the substitution of variable names, class names, and strings in Xcode
In doing iOS development code optimization work, before optimizing the code structure, we should first tidy up the project's appearance, the file and class naming to standardize, in Xcode provides us with a convenient and powerful name modification function.
First step: Modify the class name
Place the mouse click on the name of the class and select Edit->refactor->rename in the Xcode toolbar:
After that, change the class name to the mode we need to click Preview, and remember to check the following associated file:
Xcode will detect where we need to change and click Save when you're through.
The second step modifies the related string:
With the first step, the file name of our class, the class name has been changed, but not comprehensive, because some comments, strings dynamically created class objects and class functions when creating class objects are not changed, we need to do this step, the class name before the change in the search bar to the left of Xcode search:
To re-elect find to replace:
There are four options, meaning the following:
Containing: Retrieving objects that contain search criteria
Matching: Retrieving an object equal to the search criteria
Start with: Retrieves an object that begins with a search condition
Ending with: Retrieving objects that end with a retrieval condition
We choose matching, retrieve it, replace it with the retrieved place, and with this step we can replace the comments in the code, the string, the class method, and the associated Id,cell complex in the Xib and storyboard files.
Step three: Modify the name of the variable in the file
In the file, we can also swap out the search box by command+f, and replace the find with the replace retrieve for the variable we want.
Modify the substitution of variable names, class names, and strings in Xcode