I'm trying to learn how to get a timer working... I read the apple docs on timers and loops. I also went through the loop and nstimer class docs. Finally I went through the chapter on NSTimer in cocoa programming for mac os x. Here's my unsuccessful code. (I just checked, all my connections are good. As far as I can tell it should work. Pressing "go" does nothing though...)
#import <Cocoa/Cocoa.h>
@interface AppController : NSObject/* Specify a superclass (eg: NSObject or NSView) */ {
IBOutlet id progressBar;
NSTimer *timer;
int count;
}
- (IBAction)goid)sender;
- (IBAction)resetid)sender;
- (IBAction)stopid)sender;
@end
#import "AppController.h"
@implementation AppController
- (IBAction)goid)sender {
timer=[[NSTimer scheduledTimerWithTimeInterval:0.1 target:self selectorselector(increment userInfo:nil repeats:YES] retain];
}
- (IBAction)resetid)sender {
}
- (IBAction)stopid)sender {
}
- (void)incrementNSTimer *)aTimer {
count=count+1;
[progressBar setIntValue:count];
}
@end
Can anyone tell me what's wrong? Thanks! Nate
#import <Cocoa/Cocoa.h>
@interface AppController : NSObject/* Specify a superclass (eg: NSObject or NSView) */ {
IBOutlet id progressBar;
NSTimer *timer;
int count;
}
- (IBAction)goid)sender;
- (IBAction)resetid)sender;
- (IBAction)stopid)sender;
@end
#import "AppController.h"
@implementation AppController
- (IBAction)goid)sender {
timer=[[NSTimer scheduledTimerWithTimeInterval:0.1 target:self selectorselector(increment userInfo:nil repeats:YES] retain];
}
- (IBAction)resetid)sender {
}
- (IBAction)stopid)sender {
}
- (void)incrementNSTimer *)aTimer {
count=count+1;
[progressBar setIntValue:count];
}
@end
Can anyone tell me what's wrong? Thanks! Nate