There is no difference between
@implementation ClassA
static NSString *str = nil;
.....
@end
and
static NSString *str = nil;
@implementation ClassA
.....
@end
They work the same way ...
Static variables help give the class
object more functionality than just
that of a "factory" producing
instances; it can approach being a
complete and versatile object in its
own right. A class object can be used
to coordinate the instances it
creates, dispense instances from
lists of objects already created, or
manage other processes essential to
the application. In the case when you
need only one object of a particular
class, you can put all the object's
state into static variables and use
only class methods. This saves the
step of allocating and initializing
an instance.