I have a protocol class where I'm defining multiple String Constants and Array Constants containing these strings. I am porting over an android project.
In my Constants.h
, I am declaring the NSString
& NSArray
constants as follows:
#imports.....
extern NSString *const constant1;
extern NSString *const constant2;
extern NSArray *const constantArr;
@protocol.....
Then in my Constants.m
, I'm defining these constants:
#import "Constant.h"
NSString *const constant1 = @"Constant1";
NSString *const constant2 = @"Constant2";
//I get an error at this line
NSArray *const constantArr = [NSArray arrayWithObject: constant1, constant2, nil];
I get an error when defining the NSArray, it says Initializer element is not a compile-time constant
. I believe I may be going about initialising the NSArray constant the wrong way.
Has anyone come across a similar issue or knows a way to initialise an NSArray Constant? Thanks