hi there...
i'm having a problem with my quit function... my app will only quit if i quite twice that is, i have to press Apple+Q two times for the app to terminate.
it may or may not have to do with my timer... i'm not sure... but something very strange is happening to the object as the "quitApplication" action will be added twice, no matter how many times i rewrite and set up the object. i've included an image to show you what i mean:
here's the code for the Fade Controller:
FadeController.h
FadeController.m
i'm having a problem with my quit function... my app will only quit if i quite twice that is, i have to press Apple+Q two times for the app to terminate.
it may or may not have to do with my timer... i'm not sure... but something very strange is happening to the object as the "quitApplication" action will be added twice, no matter how many times i rewrite and set up the object. i've included an image to show you what i mean:
here's the code for the Fade Controller:
FadeController.h
Code:
#import <Cocoa/Cocoa.h>
@interface FadeController : NSObject {
IBOutlet NSWindow *mainWindow;
NSTimer *timer;
}
- (IBAction)quitApplication:(id)sender;
@end
FadeController.m
Code:
#import "FadeController.h"
@implementation FadeController
- (void)awakeFromNib {
[mainWindow setDelegate:self];
[mainWindow setAlphaValue:0.01];
timer = [[NSTimer scheduledTimerWithTimeInterval:0.05 target:self selector:@selector(fadeIN:) userInfo:nil repeats:YES] retain];
}
- (void)fadeIN:(NSTimer *)theTimer {
if ([mainWindow alphaValue] > 0.0) {
[mainWindow setAlphaValue:[mainWindow alphaValue] + 0.1];
}
else
{
[timer invalidate];
[timer release];
timer = nil;
}
}
- (IBAction)quitApplication:(id)sender {
[mainWindow setAlphaValue:1.0];
timer = [[NSTimer scheduledTimerWithTimeInterval:0.05 target:self selector:@selector(fadeOUT:) userInfo:nil repeats:YES] retain];
}
- (void)fadeOUT:(NSTimer *)theTimer
{
if ([mainWindow alphaValue] > 0.0) {
[mainWindow setAlphaValue:[mainWindow alphaValue] - 0.1];
}
else
{
[timer invalidate];
[timer release];
timer = nil;
[NSApp terminate:nil];
}
}
@end