Constants that can be used throughout the Xcode project

Source: Internet
Author: User

During iOS development, it is possible to use constants on multiple pages, such as the coordinates of a control, the fixed spacing of controls, enumerations, and so on.

Below is a small way to define these constants in a specialized class (for later modification and management) and import the header file into the PCH file, which can be called anywhere, as follows:

1. Create a new class, Inherit from NSObject

2. Clear all the contents of. h and. M, note: keep #import <uikit/uikit.h> in two files , because sometimes you need to define some CGFloat constants

3. h files are some constant names beginning with Uikit_extern , and. m files assign values to constants

4. These constants are defined at this time, and then the class name of the class is copied to the PCH file to ensure that the value of the defined constant can be obtained directly from anywhere

5, this time in any controller, Model, view call these constants

a small partner in need can try to play -. -

Constants that can be used throughout the Xcode project

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.