I have a singleton as class method:
+(WordsModel *) defaultModel{
static WordsModel *model = nil;
if (!model) {
model = [[[self alloc] init] autorelease];
}
return model;
}
What happens with the static reference to model inside the method? Will it ever get released?
It won’t work as you are autoreleasing your instance of your class…
On the next runloop, it will be released…
Take a look at the standard singleton patterns:
http://www.cocoadev.com/index.pl?SingletonDesignPattern
The static instance should be a global variable, that will be freed when your app exits…