Sounds to me like you're coming from a Java-style language background, as do I (sorry if I'm guessing wrong here). I wondered about this too for a while, and then I noticed how Apple defines enums and uses them to define constants like you're describing.
Let's use the imaginary class Event
as an example:
In the header file, you want to define a new enum:
typedef enum {
kEventType_EventName1,
kEventType_EventName2,
kEventType_EventName3
}EventType; //this is the name of the new type
where EventName1
etc, is replaced with the actual names of the events you want (ie. kEventType_Direct
.
Any other class that needs to see these event types just needs to import your Event.h file:
#import "Event.h"
Then you can use EventType
as you would any other variable type (bearing in mind that it is not an NSObject, and does cannot be retained, released, etc - you would treat it like any other C type: int, float, etc)
You can even have EventType typed variables as members of other classes, so long as those classes import your Event.h header.
But that allows you to do things like this:
-(void) handleEventOfType: (EventType) evtType {
switch(evtType) {
case kEventType_EventType1 :
//stuff here
break;
//etc...
}
}
That's the best way I've seen to do it so far, and seems to be the way that is generally practiced abroad (at least in most of the projects that I've seen). Anyway, hope that helps!