Question

Prefixing a variable declared outside of any scope with the keyword static prevents that variable from being externally accessible. However, does it limit the scope from a category using it?

Foo.m
@implementation Foo

static void* FooContext = &FooContext;

- (void)methodThatUsesFooContext { ... }

@end


Foo+SpecialSauce.h
@implementation Foo (Special Sauce)

- (void)anotherMethodThatWouldLikeToUseFooContext { ... }

@end
Was it helpful?

Solution

Static variables declared at the top-level of a file (i.e., outside of any functions or method calls) are visible to anything within that file.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top