I am a noob to ObjC programming. I am trying to write a simple stopwatch app to get my feet wet but I am having a problem with the timer function.
compiler warns me that 'NSTimer' may not respond to '+scheduledTimerWithTimeInterval:target:selector:userinfo:repeats:'
When I run my app I get an exception: +[NSObject doesNotRecognizeSelector:]
Which then of course dumps my app.
Thanks to anyone who can help a newbie moron. :)
Here is my code.
.h file ................................................................................... #import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
@interface ActiveStructController : NSObject {
IBOutlet UILabel *ActiveLabel;
NSTimer *repTimer;
NSTimer *timer;
}
- (IBAction)ChangeActiveLabel:(id)sender;
- (IBAction)PauseButtonClick:(UIButton *)sender;
- (IBAction)StartButtonClick:(UIButton *)sender;
- (IBAction)StopButtonClick:(UIButton *)sender;
- (void) updClk:(NSTimer *)sender;
@property (assign) NSTimer *repTimer;
@end
....................................................................................
.m file
....................................................................................
#import "ActiveStructController.h"
#import "StopWatch_BasicAppDelegate.h"
@implementation ActiveStructController
@dynamic repTimer;
- (IBAction)ChangeActiveLabel:(id)sender {
}
- (IBAction)PauseButtonClick:(UIButton *)sender {
}
- (IBAction)StartButtonClick:(UIButton *)sender {
timer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(updClk:) userinfo:self repeats:YES];
self.repTimer = timer; // reference to timer
}
- (IBAction)StopButtonClick:(UIButton *)sender {
[repTimer invalidate];
[repTimer release];
}
- (void)updClk:(NSTimer *)theTimer
{
int MinuteVal = 20;
int SecondVal = 00;
NSLog (@"Got Here %d:%d",MinuteVal,SecondVal);
}
@end
Hotmail has tools for the New Busy. Search, chat and e-mail from your inbox. Learn more.
|