Pretty horrendous newbie question here.
I'm looking at the following apple example source code:
/*
Cache the formatter. Normally you would use one of the date formatter styles (such as NSDateFormatterShortStyle), but here we want a specific format that excludes seconds.
*/
static NSDateFormatter *dateFormatter = nil;
if (dateFormatter == nil) {
dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"h:mm a"];
}
Trying to figure out:
Why use the static keyword?
How this equates to a cached variable if you set it to nil each time the method is called.
The code is from Example 4 in the Tableview Suite demo