开发者

specifying @selector for method on another object?

开发者 https://www.devze.com 2023-02-13 16:02 出处:网络
Quick question, is there a way to specify a @selector that is a met开发者_如何转开发hod on another object. Currently I have fudged a solution by using a local method to call the remote method, but it

Quick question, is there a way to specify a @selector that is a met开发者_如何转开发hod on another object. Currently I have fudged a solution by using a local method to call the remote method, but it feels clunky.

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

.

- (void)timerLocation {
    [[self dataModel] startUpdatingLocation];
}


That's what the target portion of the NSTimer scheduledTimerWithTimeInterval:target:selector:userInfo:repeats: method is for. (i.e.: You specify the object you want to call as the target and the name of the object's method as the selector.)


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

精彩评论

暂无评论...
验证码 换一张
取 消