Hi I am basically making a simple timer amongst other things using NSTimer.
I have code to remember the start date (NSDate) and then a repeating timer fires every second to update the interface. I find that the timer fires correctly and the selector is called, but I get an exception on the first line. Any help is much appreciated.
The code with irrelevant bits missed:
#import <Foundation/Foundation.h>
@interface PPTTimer : NSObject
{
NSTimer *mainTimer;
NSDate *startTime;
NSTimeInterval timerDuration;
NSTimer *clockTimer;
NSTimer *safariTimer;
}
- (void)startTimerForHours:(int)hours minutes:(int)mins;
- (void)pauseTimer;
- (void)resumeTimer;
- (void)finishTimer;
- (void)endTimer:(NSTimer *)theTimer;
- (void)updateClockFire:(NSTimer *)theTimer;
- (void)safariCheckFire:(NSTimer *)theTimer;
@property (assign) IBOutlet NSTextField *leftField;
@property (assign) IBOutlet NSTextField *rightField;
@property (assign) IBOutlet NSTextField *leftLabel;
@property (assign) IBOutlet NSTextField *rightLabel;
@end
#import "PPTTimer.h"
@implementation PPTTimer
@synthesize leftField = leftField_;
@synthesize rightField = rightField_;
- (void)startTimerForHours:(int)hours minutes:(int)mins
{
startTime = [NSDate date];
timerDuration = 60*(mins+60*hours);
mainTimer = [NSTimer scheduledTimerWithTimeInterval:timerDuration target:self selector:@selector(endTimer:) userInfo:nil repeats:NO];
clockTimer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(updateClockFire:) userInfo:nil repeats:YES];
safariTimer = [NSTimer scheduledTimerWithTimeInterval:10 target:self selector:@selector(safariCheckFire:) userInfo:nil repeats:YES];
}
the selector code, screenshot with error:
Here's (the relevant bit of) the AS code, remember that the PPTTimer has a blue cube and that is linked to the missing value…
property parent : class "NSObject"
--app classes
property PPTTimer : missing value
--windows
property winMain : missing value
property winTimer : missing value
--IB objects
property hourField : missing value
property minuteField : missing value
on startTimerButton_(sender)
winMain's orderOut_(sender)
winTimer's makeKeyAndOrderFront_(sender)
PPTTimer's startTimerForHours_minutes_(hourField's intValue(), minuteField's intValue())
end startTimerButton_