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