Constants by another name
Posted
by Dave DeLong
on Stack Overflow
See other posts from Stack Overflow
or by Dave DeLong
Published on 2010-05-26T02:02:06Z
Indexed on
2010/05/26
2:11 UTC
Read the original article
Hit count: 309
First off, I've seen this question and understand why the following code doesn't work. That is not my question.
I have a constant, which is declared like;
//Constants.h
extern NSString * const MyConstant;
//Constants.m
NSString * const MyConstant = @"MyConstant";
However, in certain contexts, it's more useful to have this constant have a much more descriptive name, like MyReallySpecificConstant
. I was hoping to do:
//SpecificConstants.h
extern NSString * const MyReallySpecificConstant;
//SpecificConstants.m
#import "Constants.h"
NSString * const MyReallySpecificConstant = MyConstant;
Obviously I cannot do this (which is explained in the linked question above).
My question is:
How else (besides something like #define MyReallySpecificConstant MyConstant
) can I provide a single constant under multiple names?
© Stack Overflow or respective owner