Static locals are shared between method calls AND instances.
You can think of them as globals which are visible only inside their methods:
- (void) showVars {
int i = 0;
static int j = 0;
i++; j++;
NSLog(@"i = %i ; j = %i", i, j);
}
[…]
[obj1 showVars];
[obj2 showVars];
[obj1 showVars];
[obj2 showVars];
Above calls on 2 different instances will output:
i = 1 ; j = 1
i = 1 ; j = 2
i = 1 ; j = 3
i = 1 ; j = 4