#import "alertHandle.h" @implementation alertHandle - (IBAction)close:(id)sender { timer = [[NSTimer scheduledTimerWithTimeInterval:0.02 target:self selector:@selector(fade:) userInfo:nil repeats:YES] retain]; } - (void)fade:(NSTimer *)theTimer { if ([window alphaValue] > 0.0) { // If window is still partially opaque, reduce its opacity. [window setAlphaValue:[window alphaValue] - 0.1]; } else { // Otherwise, if window is completely transparent, destroy the timer and close the window. [timer invalidate]; [timer release]; timer = nil; [window close]; // Make the window fully opaque again for next time. [window setAlphaValue:1.0]; } } @end