Modify the substitution of variable names, class names, and strings in Xcode

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.