如果我取消注释发布声明,这个程序就会崩溃。我知道我过度释放并很快意识到这一点。但是,只是为了测试僵尸,我打开了它们(NSZombiesEnabled = YES 和 CFZombieLevel = 16),程序运行良好并且没有抛出异常。
是什么赋予了?我以为打开僵尸会告诉我我是多么愚蠢……不解决它。
#import "AppController.h"
@implementation AppController
-(IBAction)countCharacters:(id)sender {
//did a button do this?
if(![sender isKindOfClass:[NSButton class]]) {
NSLog(@"%@ is not a button", sender);
return;
}
//proceed
NSString *userString = [textField stringValue];
NSNumber *count = [NSNumber numberWithInt:[userString length]];
NSString *outputString = [NSString stringWithFormat:@"'%@' has %@ characters.",
userString, count];
//[userString release];
//[count release];
[labelField setStringValue:outputString];
//[outputString release];
}
@end