В Objective C я пытаюсь создать метод, который вызывается в селекторе NSTimer в конструкторе. Тем не менее, я получаю эту ошибку, которая приводит к сбою моего приложения при сборке:
Несовместимые типы указателей, отправляющие «void (void)» параметру типа «SEL _Nonnull»
@implementation Employee
void timerMethod(void);
- (id)init {
self = [super init];
if (self) {
_person = [[Person alloc] init];
_timer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:(timerMethod) userInfo:nil repeats:YES];
}
return self;
}
int counter = 0;
int timeUp = 10;
- (void) timerMethod {
counter += 1;
while (counter != timeUp) {
NSLog(@"A new person has been added");
[_timer invalidate];
counter ++;
}
}