Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

RossOliver

macrumors regular
Original poster
Nov 6, 2006
157
0
Hey,

I have two classes, ClassA and ClassB. In the ClassB header I have:

Code:
typedef enum_AType
{
   ATypeA,
   ATypeB,
   ATypeC
} AType;

In the ClassA header I have a method prototype:

Code:
-( AType )someMethod;

This set up only works if I include the ClassB header file in the ClassA header file - which I don't want to do (since it's against convention). I want the ClassB header to be included in the ClassA .m file. Do I need to do a @class equivalent for the type?

Cheers
 

robbieduncan

Moderator emeritus
Jul 24, 2002
25,611
893
Harrogate
There is not equivalent to a @class for an enum. Simply stick the typedef in a new .h file and include this in both of the class .h files.
 

RossOliver

macrumors regular
Original poster
Nov 6, 2006
157
0
There is not equivalent to a @class for an enum. Simply stick the typedef in a new .h file and include this in both of the class .h files.

Ah, I was hoping for a more elegant solution - but if one doesn't exist I guess I have to put it in a separate header file or include ClassB.h in ClassA.h...

Cheers

[edit]

Out of interest - Cocoa conventions state always to @class in the header and #include in the source, but looking through the UIKit framework there are a lot of #include's in the header files:

Code:
UIDatePicker.h:

#import <Foundation/Foundation.h>
#import <UIKit/UIControl.h>
#import <UIKit/UIKitDefines.h>

UILabel.h:

#import <Foundation/Foundation.h>
#import <CoreGraphics/CoreGraphics.h>
#import <UIKit/UIView.h>
#import <UIKit/UIStringDrawing.h>
#import <UIKit/UIKitDefines.h>

Any particular reason for this?
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.