IOS Dev (46) iOS Enumeration

Source: Internet
Author: User

IOS Dev (46) iOS Enumeration

  •  
  • Isn't it C?

    Yes, it is C, so the way you use C's enumeration definition is OK. As follows:

    Typedef enum {TypeA = 0, TypeB, TypeC, TypeD} MyType;

    MyType is the name of the enumeration type. The possible values are TypeA, TypeB, TypeC, and TypeD. The value of TypeA is 0, followed by 1, 2, and 3.

    What is the unique method of iOS?
    Typedef NS_ENUM (NSInteger, MyType) {TypeA = 1, TypeB = 2, TypeC = 3, TypeD = 4 };

    NS_ENUM is used to define enumeration, NSInteger is the enumerated value, and MyType is the name of the enumeration class.

    Common bit notation
    Typedef NS_ENUM (uint, Test) {TestA = 1, TestB = 1 <1, TestC = 1 <2, TestD = 1 <3, testE = 1 <4 };
    Multiple values can be obtained for enumeration instances.

    For example, the preceding example includes Test:

    Test t = TestA | TestB | TestC;

    Reprinted please indicate the blog from laruence: http://prevention.iteye.com

Related Article

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.