Video Tutorial: Objective-C Data Types: Enum & Bitmask

Learn how to add enumeration and bitmask types in Objective-C, using the new NS_ENUM and NS_OPTIONS keywords.

Challenge

Your challenge is to replace the NS_ENUM with the old-style way of doing things:

enum tag_VideoGameType {
    VideoGameTypeRPG,
    VideoGameTypeStrategy,
    VideoGameTypeAction,
    VideoGameTypeFPS
};
typedef int VideoGameType;

Then delete the default condition in your case statement. What advantage of NS_ENUM does this show you?

Download solution

Helpful links

Errata

  • When discussing the bitwise-or operator (|), I misspoke and called it the OR operator (||).
  • I said that you use the command-I key to indent code, but actually it is control-I.

Add a rating for this content

Contributors

Comments