Pregunta

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
¿Fue útil?

Solución

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.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top