Is it possible to dynamically reference a constant in objective c:
e.g. NSForegroundColorAttributeName
is declared in UIKit/NSAttributedString.h as a const NSString
. Its value is @"NSColor"
. In compiled code, I just specify the constant to use it, but what if I need to refer to it dynamically at run time (say a user might type it out)?
I could just use @"NSColor"
, but that may change as the SDK changes.
Is there a function like NSClassFromString
, say ConstFromString
:
ConstFromString(@"NSForegroundColorAttributeName") --> @"NSColor"