Declaring and checking/comparing (bitmask-)enums in Objective-C

前端 未结 4 592
旧时难觅i
旧时难觅i 2020-12-07 06:51

You know in Cocoa there is this thing, for example you can create a UIView and do:

view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIV         


        
4条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-07 07:45

    While @Regexident has provided an excellent answer - I must mention the modern Objective-C way of declaring Enumerated options with NS_OPTIONS:

    typedef NS_OPTIONS(NSUInteger, DownloadViewStatus) {
      FileNotDownloaded = 0,
      FileDownloading   = 1 << 0,
      FileDownloaded    = 1 << 1
    };
    

    Further Reference:

    • NSHipster
    • I Am The Walrus

提交回复
热议问题