그래서 1 초마다 새로 고침을하여 레이블을 업데이트하려고합니다. 불행히도 어떤 이유로 트리거가 아닙니다. 코멘트와 함께 아래 코드.NSTimer가 레이블을 업데이트하지 않습니다.
import UIKit
class ViewController: UIViewController {
@IBOutlet var tt_CountDown: UILabel!
var tt_currentDate = NSDate()
var tt_objCalendar = NSCalendar.currentCalendar()
override func viewDidLoad() {
super.viewDidLoad()
self.timeClassManagement()
//The timer I'm using to call the function to repeat
var timer = NSTimer.scheduledTimerWithTimeInterval(1, target: self, selector: Selector("timeClassManagement"), userInfo: nil, repeats: true)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
func timeClassManagement(){
//the function that holds the code for the label below
tt_CountDown.text = "\(String(tt_hour)):\(String(tt_minute)):\(String(tt_second))"
}
}
타이머는 실제로 멈추지 않습니다. 그것은 대부분의 시간을위한 시계입니다. tt_CountDown이 nil이 아니라는 것을 어떻게 증명할 것인가? 신속한 답변 ... 응답 해 주셔서 감사합니다! – user3708761
멈추지 않으면이 뷰를 다시로드하면 메모리 문제가 발생합니다 (타이머 두 개, 세 개, 네 개 등) – borrrden
그러나 실제로 tt_hour tt_minute 등을 어디에서 업데이트합니까? ? – borrrden