I am trying to set up a running loop, and to do so I’ve the following code:
[[NSRunLoop currentRunLoop] addTimer:a forMode:NSEventTrackingRunLoopMode];
However I get an error saying “Use of undeclared identifier ‘a'”. I have both of these methods declared in my header and main file:
//AppController.h
#import <Foundation/Foundation.h>
@interface AppController : NSObject
- (IBAction) startLoop: (id)sender;
- (void) a: (id)sender;
@end
//AppController.m
#import "AppController.h"
@implementation AppController
-(IBAction) startLoop: (id) sender {
[[NSRunLoop currentRunLoop] addTimer:a forMode:NSEventTrackingRunLoopMode];
}
-(void) a: (id) sender {
//Code here
}
@end
I’m new to Objective-C so I apologise in advance for any silly mistakes, thanks.
The
addTimer::method wants its first parameter to be a NSTimer object. The only thing visible in your code that’s (almost) calledais not only not a NSTimer, but not an object at all. It’s a method. Do you have a timer created somewhere that you intended to use?(Technically, the method’s name is
a:rather thana.)