By the end of Chapter 6, the init method looks something like this:
- (id)init
{
if(![super init])
return nil;
speechSynth = [[NSSpeechSynthesizer alloc] initWithVoice: nil];
[speechSynth setDelegate: self];
voiceList = [[NSSpeechSynthesizer availableVoices] retain];
return self;
}
We created an instance of NSSpeechSynthesizer, but never released it. We retained an instance NSArray of that came from sending the availableVoices message to NSSpeechSynthesizer. Why don’t we release these guys after we’re all done with them?
That is, why don’t we have a dealloc method as below?
- (void)dealloc
{
[speechSynth release];
[voiceList release];
[super dealloc];
}