PDA

View Full Version : deallocating static instance




sujithkrishnan
Aug 26, 2008, 09:55 AM
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..

Say...
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...