In the following code segment:
@implementation Foo
NSString* bar = @"Some text.";
...
@end
Is bar a static variable, or is it some kind of class or instance variable? Specifically, how is it different than doing the following:
static NSString* bar = @"Some text.";
@implementation Foo
...
@end
In the first example,
baris a global variable, with global linker visibility to the outside world..In the second example,
baris a static variable, with local-file-only visibility (i.e., the symbol is not visible outside the current compilation unit).For both examples, their positioning relative to the Objective-C keyword
@implementationis irrelevant. They have absolutely nothing to do with an Objective-C class, and operate the same whether in or out of the@implementationscope.