开发者

Calling Instance Method from the Objective C Selector

开发者 https://www.devze.com 2023-01-20 04:03 出处:网络
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:

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

精彩评论

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