Alex Rivera | Logout

What is a typedef enum in Objective-C?

Asked 2009-04-01T21:59:43.937
1111

I don't think I fundamentally understand what an enum is, and when to use it.

For example:

typedef enum {
    kCircle,
    kRectangle,
    kOblateSpheroid
} ShapeType;

What is really being declared here?

Edit
Report

1 Answer

34

A user defined type that has the possible values of kCircle, kRectangle, or kOblateSpheroid. The values inside the enum (kCircle, etc) are visible outside the enum, though. It's important to keep that in mind (int i = kCircle; is valid, for example).

answered 2009-04-01T22:04:21.930

Your Answer