2

I have a constants.h file that looks something like

#ifndef constants_h
#define constants_h

#define MyAdUnitID @"XXXXXXX"
#define GoogleAnalyticsID = @"XXXXX"

#endif

and want to reference it throughout my other implementation files. These are just simple string values that I want as NSString instances throughout my program, but can't seem to get it to work.

If there is a better practice to this, please let me know!

Bert B.
  • 579
  • 2
  • 12
  • 26
  • 3
    why not just use extern const? try this: http://stackoverflow.com/questions/3497088/objective-c-define-vs-const-vs-static – Polyov Aug 06 '12 at 01:54

1 Answers1

7

Use extern instead of define.

in .h:

extern NSString* SHKFacebookAppID;

in .m:

NSString* SHKFacebookAppID = @"1234567890";
fannheyward
  • 18,599
  • 12
  • 71
  • 109