Axeva
Axeva

Reputation: 4737

The proper location for #define statements in Objective-C

What is the proper place to put #define statements in Objective-C?

They technically work in a number of locations, but what is the "right" place to put them?

Between the #include statements and the @interface statement in my .h file??

#import <UIKit/UIKit.h>

#define BAR        1
#define FOO        2

@interface MyViewController : UIViewController

Or perhaps inside the @interface statement?

#import <UIKit/UIKit.h>

@interface MyViewController : UIViewController

#define BAR        1
#define FOO        2

Is there a best practice I should be following?

Upvotes: 2

Views: 709

Answers (1)

rmaddy
rmaddy

Reputation: 318955

When used in a .h file like this, I treat them like they are global variables. Therefore I put them after the import statements and before the interface. In other words, like your first option.

Upvotes: 7

Related Questions