0

I have declared a constant header file : "Constants.h". It contains the declarations below:

extern const NSString   *Const_alertPayantMessage = @"test";
extern const NSString   *Const_alertPayantTitle   = @"Wooooops!!!";
extern const int        *Const_statutPayant       = 1;

And I used this constants in this way:

int x = 1;

    if (x == Const_statutPayant) {
        UIAlertView* mes=[[UIAlertView alloc] initWithTitle:Const_alertPayantTitle
                                                    message:Const_alertPayantMessage delegate:self cancelButtonTitle:@"Ok" otherButtonTitles: nil];

        [mes show];
        [avPlayerError play];
    }else{
        [avPlayer play];

Unfortunately, I can not run my application because I have this error message:

clang: error: linker command failed with exit code 1 (use -v to see invocation)

Have you got any idea?

Gaurav
  • 69
  • 1
  • 6
SAP DEV
  • 111
  • 9
  • 1
    Mark's answer is correct. But might I suggest that you avoid using capital letters at the start of your variable names, from a coding standards point of view, it is often advised to start variables with a lower case letter so that they are quickly and easily distinguished from classes – Tim Apr 11 '13 at 11:41
  • In fact, I do not know the programming standards in Xcode. Each language has its peculiarities. Thx you for your additional information. – SAP DEV Apr 11 '13 at 19:06

2 Answers2

3

"Constants.h" should contain:

extern const NSString   *Const_alertPayantMessage;
extern const NSString   *Const_alertPayantTitle;
extern const int        Const_statutPayant;

"Constants.m" should contain:

const NSString   *Const_alertPayantMessage = @"test";
const NSString   *Const_alertPayantTitle   = @"Wooooops!!!";
const int        Const_statutPayant       = 1;
Mark Kryzhanouski
  • 7,251
  • 2
  • 22
  • 22
0

Your Constant.h should be like

NSString   *  const kAlertPayantMessage;
NSString   *  const kAlertPayantTitle;

And your Constant.m should be like

NSString   *  const kAlertPayantMessage = @"test";
NSString   *  const kAlertPayantTitle   = @"Wooooops!!!";  

Why you have to use NSString* const instead of const NSString * ?

Community
  • 1
  • 1
Anil Varghese
  • 42,757
  • 9
  • 93
  • 110