Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Objective C - Where do you dealloc global static variables?

Or, what is the opposite of +(void)initialize?

Here's my situation:

I have a class Unit, whose -(id)initWithName: function takes data from a global NSDictionary, which is created lazily, defined in the Unit.m file as:

static NSMutableDictionary *unitLibrary = nil;

Where do I call [unitLibrary release]?

like image 666
abtree Avatar asked Oct 06 '09 23:10

abtree


1 Answers

You can call it at a location in which you know the dictionary is not needed anymore. If it is needed throughout the entire lifecycle of the application, then you don't have to do anything as all memories will be reclaimed by the OS when the app terminates.

like image 65
Boon Avatar answered Oct 03 '22 03:10

Boon