Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/119.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在iOS中每1秒自动调用一个方法。?_Ios - Fatal编程技术网

如何在iOS中每1秒自动调用一个方法。?

如何在iOS中每1秒自动调用一个方法。?,ios,Ios,我想在iOS中的一个方法中编写一些代码,该方法应该每1秒调用一次。 有人能帮我做这件事吗。 提前谢谢 [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(thisIsCalledEvery1Second:) userInfo:nil repeats:YES]; 这是一个非常常见的问题。这里不用问。你可以通过搜索谷歌或者其他老问题很容易找到这个问题。我加上这个code

我想在iOS中的一个方法中编写一些代码,该方法应该每1秒调用一次。 有人能帮我做这件事吗。 提前谢谢

[NSTimer scheduledTimerWithTimeInterval:1.0
    target:self
    selector:@selector(thisIsCalledEvery1Second:)
    userInfo:nil
    repeats:YES];

这是一个非常常见的问题。这里不用问。你可以通过搜索谷歌或者其他老问题很容易找到这个问题。我加上这个code@vijay添加要启动action.viewdidload或按钮actionTimer.scheduledTimer的位置(withTimeInterval:,repeats:true,block:{(timer)in print(“那花了一秒钟”)})