Saturday, 8 June 2013

Scope difference between static and non static variables in Objective-c

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];
}

No comments:

Post a Comment