I’m trying to create a enumeration class in objective-c. Here below is what I already got.
#import <Foundation/Foundation.h>
typedef enum {
Car,
Bike,
Boat
} Vehicle;
@interface ModelVehicle : NSObject {
Vehicle vehicle;
}
@property (nonatomic) Vehicle vehicle;
@end
Now I can access the enum from another class but only with the following code. Why can’t I access it with the class name where the enum in exists, for example ModelVehicle.Car?
Vehicle *hi = Car;
In Objective-C, enums aren’t a part of a class, so you reference them directly by name.