0

If I place a typedef enum{kOne,kTwo}whatever; in a .h above the @interface, I know I can use it by method implementations in the .m. That is, I can use kOne and kTwo freely.

Now, I know I can make an @property of whatever thereby exposing the chosen kValue of whatever to other classes, if desired.

But what if I want to expose the enum guts of whatever, so I can access kOne and kTwo from other classes? That is, I want to know how many are included in whatever and access those constants too. For example, I want another class to know that kOne is 0, kTwo is 1, etc.

Is there a way to do this?

Bo Persson
  • 90,663
  • 31
  • 146
  • 203
johnbakers
  • 24,158
  • 24
  • 130
  • 258

2 Answers2

3

Simply #import the appropriate header file, just as you need to in order to use the class for which it is defined.

You do not need the include guards in @dwerner's answer because you should not use #include for Objective-C headers. Use #import instead. See this question for more details.

Community
  • 1
  • 1
freespace
  • 16,529
  • 4
  • 36
  • 58
0

If I understand you correctly, you can put the typedef in it's own header, and surround with

#ifndef __MY_TYPEDEF__
typedef enum{kOne,kTwo}whatever;
#endif

and just #include this where needed.

dwerner
  • 6,462
  • 4
  • 30
  • 44