Scope difference between static and non static variables in Objective-c
What is the difference between writing
+(MyObj*)obj
{
static MyObj *obj= nil;
if(!obj)
obj = [[super allocWithZone:nil] nil];
}
and
+(MyObj*)obj
{
MyObj *obj= nil;
if(!obj)
obj = [[super allocWithZone:nil] nil];
}
What is the difference between writing
+(MyObj*)obj
{
static MyObj *obj= nil;
if(!obj)
obj = [[super allocWithZone:nil] nil];
}
and
+(MyObj*)obj
{
MyObj *obj= nil;
if(!obj)
obj = [[super allocWithZone:nil] nil];
}
No comments:
Post a Comment