从Objective C Selector调用实例方法

时间:2010-10-12 16:43:56

标签: iphone cocos2d-iphone

是否可以从选择器调用对象的实例方法?以下可能吗?它给我编译错误“:”缺少或者是什么:

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

2 个答案:

答案 0 :(得分:2)

将目标更改为self.person并使用舞蹈选择器:

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

答案 1 :(得分:0)

您是否尝试过更改目标?像这样:

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