As others have pointed out, static class methods have a prefix with a plus (+) declaration, for example:
@interface MyClass : NSObject + (void)myClassMethod; @end
Objective-C does not make static properties as simple, and you need to jump over the following hoops:
- declare a static variable
- configure getter and setter methods to access it
- save value
Full example:
static NSString* _foo = nil; @interface MyClass : NSObject + (NSString *)getFoo; + (void)setFoo; @end // implementation of getter and setter + (NSString *) getFoo { return _foo; } + (void) setFoo:(NSString*) value { if(_foo != value) { [_foo release]; _foo = [value retain]; } }
I'm not an Obj-C expert, but it seems to work well in my code. Correct me if something is disabled here.
Michael teper
source share