如何为计数设置NSTimer限制?
首先,为了了解我的问题,这里是我的Xcode项目的屏幕截图 - http://i.gyazo.com/178450cfdbf45a2508856cc79fd215ec.png
其次,这里是解释出错的代码 -
link_to
我尝试这样做,代码对程序的执行没有影响。在timerMaximum变量(我确定是全局的)之后,计时器继续计数。
我认为这与...有关...
<%= link_to post_url(@post) do %>
<h2 class="post-title">
<%= post.title %>
</h2>
<h3 class="post-subtitle">
<%= post.subheading %>
</h3>
<% end %>
虽然,我不太确定。
有人能帮助我吗?
非常感谢!
杰基答案 0 :(得分:0)
在counting
方法中检查并限制timerCount。喜欢:
func Counting() {
timerCount+=1
if timerCount == timeraximum {
self.stop()
}
else {
timerLabel.text =“\(timerCount) seconds”
}