View Full Version : dealloc method not executing

Aug 20, 2007, 04:26 PM
Hey all,

i have a very simple cocoa app that counts the letters in a NSTextField. I have a controller object with outlets and actions defined to do the work. This controller object has a dealloc method but it doesn't seem to execute when the application ends and is being deallocated. Everything else executes as expected except for the dealloc. I even put a breakpoint in the code to see if it executes but it never breaks in dealloc.Below is the code.

Any ideas / suggestions are welcome.

#import "AppController.h"

@implementation AppController

- (IBAction)countLetters: (id)sender
NSString *message = [inputTextBox stringValue] ;
int length = [message length] ;
NSString *newMessage = [NSString stringWithFormat:@"%@ has %d letters",message,length] ;
[letterCounter setStringValue:newMessage] ;

NSLog(@"Set new value to %@",message) ;


- (void) dealloc
NSLog(@"testing....") ;
NSLog(@"Deallocating AppController") ;
[super dealloc];

- (void)awakeFromNib
[inputTextBox setStringValue:@"this is the initial string"];
NSLog(@"waking up the NIB");

- (id)init
[super init];
return self ;


Aug 20, 2007, 08:26 PM
From Apple:

Note that when an application terminates, objects may not be sent a dealloc message since the processís memory is automatically cleared on exitóit is more efficient simply to allow the operating system to clean up resources than to invoke all the memory management methods.