Call class method with argument from another class method

前端 未结 2 1194
耶瑟儿~
耶瑟儿~ 2021-01-23 11:21

In my code file MyItemVC.swift I have defined the following class and method:

class MyItemVC: UIViewController, UITextViewDelegate {

var timer          


        
相关标签:
2条回答
  • 2021-01-23 11:35

    The function you have specified is not a class function. Add class keyword before func keyword.

    The changed code:

    class func cycleTimer
    

    Note: In the previous versions of Swift you must use the following code (and also in C or other languages):

    static func cycleTimer
    
    0 讨论(0)
  • 2021-01-23 11:37

    You need to use class function to be able to use it this way.

    class func cycleTimer(toggleOn: Bool) {
    

    However, I'm not sure about thread safety.

    0 讨论(0)
提交回复
热议问题