I am attempting to create a Cocoa Framework that is an object-oriented wrapper around a procedural framework written in the Core Foundation. The procedural framework has a number of constants that are all defined as extern CFStringRef constantName
.
How should I create NSString constants that directly map to the procedural constants so that in my framework I can simply cast the NSString constant to the CFStringRef constant within the framework such that the developer using my framework does not need to be aware of the casts himself.
Every thing that I have tried results in the compiler error Initializer element is not constant
Update: This is the pattern I would like to use:
Constants.h:
extern NSString * myConstant
Constants.m:
#import "Constants.h"
NSString *myConstant = ConstantFromCFStringRef;
I am successfully declaring constant values with NSString in Constants.m using NSString *aConstant = @"someStringLiteral"
but in this case, I want to have the same value as the CFStringRefs that I cannot ignore.