iPhone延迟后调用功能 [英] iPhone calling a function after a delay
问题描述
我有一些代码,其中我将精灵显示N秒钟.N秒钟后,此框将被删除,我想调用一个我可以选择的函数.例如,我想在10秒内调用showBoxEnded.
I have some code where I display a sprite for N number of seconds. This box is removed after N seconds and I'd like to call a function that I can select. For example, in 10 seconds I want to call showBoxEnded.
我在这里看了看,发现可以使用SEL功能了.我写道:
I looked on here and saw I can use the SEL function. I wrote:
-(void)caller:(id)sender
{
NSLog(@"Function Called!");
}
我可以调用callFunc来设置将被调用的功能:
I can call callFunc in order to set the function that will be called:
-(void) callFunc:(SEL)func;
但是,当我尝试这样做时,我的函数从不被调用.我在这里想念什么吗?是否可能像C ++中那样?
However, when I try this, my function is never called. Am I missing something here? Is this possible like it is in C++?
是否可以仅将SEL函数作为参数传递给函数?
Is it possible to just pass the SEL function as a parameter to a function?
谢谢!
推荐答案
您在寻找 [self performSelector:@selector(myfunc)withObject:afterDelay:];
这篇关于iPhone延迟后调用功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!