By specifying @selector for a method on another object?

The quick question is, is there a way to specify @selector, which is a method for another object. I am currently confusing the solution using the local method to call the remote method, but it feels awkward.

[NSTimer scheduledTimerWithTimeInterval:10 target:self selector:@selector(timerLocation) userInfo:nil repeats:YES]];

.

- (void)timerLocation {
    [[self dataModel] startUpdatingLocation];
}
+5
source share
2 answers

This is what targetpart of the NSTimer method meansscheduledTimerWithTimeInterval:target:selector:userInfo:repeats: . (i.e., you specify the object that you want to call as the target, and the name of the method of the object as a selector.)

+11
source
[NSTimer scheduledTimerWithTimeInterval:10 target:someOtherObject selector:@selector(timerLocation) userInfo:nil repeats:YES];
+2
source

All Articles