Hi
I am writing an Iphone game. It's going well but I am having problems with the game loop. I am trying to use NSTimer to invoke the game loop so many times per second.
I invoke the NSTimer like this in my viewController.m
-(IBAction) createStory

id)sender {
NSLog(@"abpout to make timer");
timer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(gameloop) userinfo:nil repeats:YES];
}
In viewController.h I have declared the timer thus:
@interface FieldButtonFunViewController : UIViewController {
IBOutlet UIButton *generateStory;
NSMutableArray *_them;
NSTimer *timer;
}
I have a gameloop that looks like this:
-(void) gameloop {
NSLog(@"in gameloop");
// my other code here
}
and declare gameloop in the .h file thus:
- (void) gameloop;
When I build this I get a warning
/Users/steve/Documents/FieldButtonFun/Classes/FieldButtonFunViewController.m:80: warning: 'NSTimer' may not respond to '+scheduledTimerWithTimeInterval:target:selector:u serinfo:repeats:'
I have been trying to fix it for about 4 hours. No luck. When I run the program things work until the timer is fired then it crashes.
The following appears in the console:
2010-04-02 16:47:22.804 FieldButtonFun[6129:207] *** +[NSTimer scheduledTimerWithTimeInterval:target:selector:use rinfo:]: unrecognized selector sent to class 0x1c844a0
2010-04-02 16:47:22.805 FieldButtonFun[6129:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** +[NSTimer scheduledTimerWithTimeInterval:target:selector:use rinfo:]: unrecognized selector sent to class 0x1c844a0'
2010-04-02 16:47:22.806 FieldButtonFun[6129:207] Stack: (
29295707,
2467112201,
Any ideas ... please.
Best
Steve