I’m using a set of Constant.m files, one per target, to define specific things for each target. For example:
// Constants.h
extern NSString * const kDatabaseFileName;
//Constants.m
NSString * const kDatabaseFileName = @"target_one.sqlite";
I’d also like to define an NSArray for each of my targets:
NSArray * const kLabelNames = [[NSArray alloc] initWithObjects:
@"nameLabel", @"addressLabel", nil];
But this gives “error: initializer element is not constant”. Using ‘arrayWithObjects` doesn’t work either. Is this because the strings in my array are not constants?
How can I set up an array as a global constant? Thanks.
If you want a set of constants that includes NS types, consider placing them all in a singleton.
You could have a single header file, and multiple implementation files (one per target). As long as that all implement the class declared in the header file you should be fine.