Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

sailorfoley

macrumors newbie
Original poster
Aug 20, 2007
2
0
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:mad:"%@ 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:mad:"this is the initial string"];
NSLog(@"waking up the NIB");
}

- (id)init
{
[super init];
NSLog(@"Init...");
return self ;
}

@end
 
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.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.