Objective-C: Check if using enum option

后端 未结 4 777
醉话见心
醉话见心 2021-02-06 13:51

I have a custom object that is using a typedef enum. If I set a few of the enum options for my object, how can I check to see if those are being used?

typedef e         


        
4条回答
  •  北恋
    北恋 (楼主)
    2021-02-06 14:32

    You shouldn't use an enum for this, or at least not use the standard numbering.

    #define Option1 1
    #define Option2 2
    #define Option3 4
    #define Option4 8
    #define Option5 16
    

    The values need to be powers of two, so you can combine them. A value of 3 means options 1 + 2 are chosen. You wouldn't be able to make that distinction if 3 was a valid value for one of the other options.

提交回复
热议问题