Dodając do tego, co zostało powiedziane, jeśli chcesz zdać jeden argument, aby myFunc połączenie można zmodyfikować w następujący sposób:
[self performSelector:@selector(showNote:) withObject:@"S" afterDelay:1.0];
i jeśli trzeba wywołać metodę, która trwa dłużej niż 1 argumentu, można to zrobić za pomocą wywołania, jak pokazano w poniższym przykładzie -
SEL selector = @selector(nextPicture:);
NSMethodSignature *signature = [[self class] instanceMethodSignatureForSelector:selector];
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:signature];
[invocation setSelector:selector];
//Set the arguments
[invocation setTarget:self];
NSString* str = [imageNames objectAtIndex:1];
[invocation setArgument:&str atIndex:2];
[NSTimer scheduledTimerWithTimeInterval:5.0f invocation:invocation repeats:NO];
dzięki. również interesujące: + (void) cancelPreviousPerformRequestsWithTarget: (id) aTarget selektor: (SEL) aSelektor obiekt: (identyfikator) anArgument –
Powyższy kod ma błąd, po: nie jest potrzebne wywołanie selektora dla metod bez argumentów. [self performSelector: @selector (myFunc) withObject: nil afterDelay: 5.0]; – archieoi