2016-11-04 7 views
-1

タイマは一度動作しますが、初めて動作した後はもう動作しません...何が問題なのですか?ありがとう!タイマは1回だけ機能を実行します

override func viewDidLoad() { 
     super.viewDidLoad() 

let myTimer : Timer = Timer.scheduledTimer(timeInterval: 7, target: self, selector: (selector: "functionOne"), userInfo: nil, repeats: true) 
     } 
    } 
    func functionOne() 
    { 
     print("hello") 

    } 
+1

を - あなたのスウィフト3セレクタの構文が正しくありません。 http://stackoverflow.com/questions/24007650/selector-in-swiftを参照してください。 – rmaddy

答えて

1

このコードを試してみてください。

override func viewDidLoad() { 
    super.viewDidLoad() 
    // Do any additional setup after loading the view, typically from a nib. 

    Timer.scheduledTimer(timeInterval: 7.0, target: self, selector: #selector(functionOne), userInfo: nil, repeats: true) 

} 

func functionOne() { 
    print("hello") 
} 

出力:FYI

enter image description here

関連する問題