How to pass arguments when calling function with timer in objective c

后端 未结 7 1514
我寻月下人不归
我寻月下人不归 2020-12-20 00:02
-(void)setX:(int)x andY:(int)y andObject:(Sprite*)obj
{
    [obj setPosition:CGPointMake(x,y)];
}

Now, I want to call above method, using following

相关标签:
7条回答
  • 2020-12-20 00:39

    If you use a target-action timer, you can't have the timer directly call an arbitrary method. A timer's action must have a very specific signature. You can pass additional data in the userinfo dictionary and have the timer's action call the method you ultimately want, or you can use the invocation form as Dave said. Personally, I usually do the former, because I find NSInvocations to be annoying and setting one up can actually take more code than just writing an intermediary method.

    0 讨论(0)
提交回复
热议问题