deallocating static instance

Discussion in 'iOS Programming' started by sujithkrishnan, Aug 26, 2008.

  1. sujithkrishnan macrumors 6502

    May 9, 2008
    Hi all..

    I am confused by thinking how/ when the dealloc in singleton instance get called?

    Can any one tell me how to release a static object..

    My code luks like below...
    // staticMyClassObj    is a static-object
    +(MyClass *)getMyClassObject
    	if(staticMyClassObj == nil)
    		staticMyClassObj = [[Catalog alloc]init];
    		staticMyClassObj.myClassDictionary = [[[NSMutableDictionary alloc] init]autorelease];
    		staticMyClassObj.itemsArray = [[[NSMutableArray alloc]init]autorelease];
    	return staticMyClassObj;
    +(void)setMyClassObject:(MyClass *)MyClassObject
    	if(staticMyClassObj !=MyClassObject)
    		[staticMyClassObj release];
    		staticMyClassObj = [MyClassObject retain];
    I am just calling [MyClass getMyClasObject].<anyProperty> to set teh values from different files...

    However i wnat the data through out the application...

    So how to release / dealloc the "staticMyClassObj" before quitting app...

Share This Page