Referencing a static NSString * const from another class

constants, objective-c, static

Solution

You should extern your string in the header, and then define the string in the implementation.

//ClassA.h
extern NSString * const kMyConstant;

//ClassA.m
NSString * const kMyConstant = @"my constant string";

//ClassB.h/m
#import "ClassA.h"

...
    NSLog(@"String Constant: %@", kMyConstant);

Problem

In class A I have this: ``` static NSString * const kMyConstant = @"my constant string"; ``` How can I reference this from class B?

Original source