How do I lookup a string constant at runtime in Objective-C?
You can use CFBundleGetDataPointerForName
to lookup a constant's value at runtime
NSString *lookupStringConstant(NSString *constantName) {
void ** dataPtr = CFBundleGetDataPointerForName(CFBundleGetMainBundle(), (__bridge CFStringRef)constantName);
return (__bridge NSString *)(dataPtr ? *dataPtr : nil);
}
Example use:
NSString *version = lookupStringConstant(@"VungleSDKVersion");
NSLog(@"Version = %@",version);