advertisement

Article:
  Creating Toolbars for Mac OS X
Subject:   Double autorelease
Date:   2002-11-04 19:25:57
From:   anonymous2
On page 2, the code says:


- (void)setupToolbar
{
NSToolbar *toolbar = [[NSToolbar alloc] initWithIdentifier:@"mainToolbar"];
[toolbar autorelease];
[toolbar setDelegate:self];
[toolbar setAllowsUserCustomization:YES];
[toolbar setAutosavesConfiguration:YES];
[mainWindow setToolbar:[toolbar autorelease]];
}


But that sends toolbar two autorelease messages. Oh the EXC_BAD_ACCESSes. :) I figured the code was right, so I left it, until I thought about it a bit, then noticed that the first message wasn't mentioned in the analysis. Anyway, removing the first -autorelease call will fix it all.