I often see singleton classes designed similar to the following:
@implementation SomeImplementation
static SomeClass *sharedSomeObject = nil;
+ (void) someClassMethod {
sharedSomeObject = [[SomeImplementation alloc] init];
// do something
}
@end
someClassMethod can be called at any time -- should it be checking for nil first before allocating a new instance of sharedSomeObject? Or, since sharedSomeObject is static, is the check unnecessary? Seeing code like this I always want to put an if (!sharedSomeObject) around the allocation.