开发者

Calling Instance Method from the Objective C Selector

Is it possible to call the instance method of an object from the selector? Is the below possible? It gives me compilation error that ":" is missing or something:

timer = [NSTimer scheduledTimerWithTimeInterval:1.0
                                         target:self
                                       selector:@selector(([self.person dance]))
                           开发者_运维百科            userInfo:nil
                                        repeats:YES];   


Change target to self.person and use the dance selector:

timer = [NSTimer scheduledTimerWithTimeInterval:1.0
                                     target:self.person
                                   selector:@selector(dance)
                                   userInfo:nil
                                    repeats:YES];


Have you tried changing the target? Like this:

timer = [NSTimer scheduledTimerWithTimeInterval:1.0
                                         target:self.person
                                       selector:@selector(dance)
                                       userInfo:nil
                                        repeats:YES];   
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜