The method alloc is just a dummy method. It’s implementation looks like this:
return [self allocWithZone:nil];
allocWithZone: will call the C function, NSAllocateObject. This function is where memory is actually allocated.
So, the goal of this singleton class is to prevent anyone from creating another instance of the class. If we were to override alloc, it would prevent the following:
id newInstance = [[SomeClass alloc] init];
However, this still leaves the possibility of doing this:
id newInstance = [[SomeClass allocWithZone:nil] init];
So, we’re preventing that from happening. If someone uses alloc, it calls our allocWithZone:. If someone uses allocWithZone:, it predictably calls our allocWithZone:, too. Another programmer can’t “jump” our alloc override because of this.