Second thing to know is that the keyword static makes a variable into what is basically an instance variable for that single method.
I disagree with calling this an "instance variable". It implies this is stored in an object, which it definitely isn't. It's stored in a single static variable that is shared by all callers of this function, across all threads. It's exactly the same as this:
Code:
static NSMutableArray *storage = nil;
- (NSArray *) allSubviews{
BOOL isFirstCall = NO;
...
In the above code, the name is visible outside the block (i.e. to other blocks or initializers in the same compilation unit), but the lifetime of the variable is absolutely identical to the "static inside the block" declaration. Even the initializer to nil is identical: it's done exactly once, conceptually when the program is loaded, before main() is called. It's not done each time the method/function is entered.
At no time is 'storage' ever an instance variable. If anything, it's a shared singleton.
One consequence of static storage is in concurrency: this code is not thread-safe. Re-entrancy is another concern, although here the function/method is re-entrant (it calls itself), and the singularity of the static storage is being relied upon by the re-entrant calls. In short, the variable has to be static because that's the only way multiple calls can use the same variable without passing it in.
To eliminate the static storage entirely would make this thread-safe. I'd probably do it by making two methods, or a method and a static function. One method (or the static function) is the recursive one with void return, and modifies its arg-array. The other method is the public one identical in name and args to allSubviews.