Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 使用NSTimer.scheduledTimerWithTimeInterval函数发送到实例的选择器无法识别_Ios_Swift_Nstimer - Fatal编程技术网

Ios 使用NSTimer.scheduledTimerWithTimeInterval函数发送到实例的选择器无法识别

Ios 使用NSTimer.scheduledTimerWithTimeInterval函数发送到实例的选择器无法识别,ios,swift,nstimer,Ios,Swift,Nstimer,我需要每分钟都运行的函数。 所以我决定使用NSTimer.scheduledTimerWithTimeInterval函数 这是我的密码 override func viewWillAppear(animated: Bool) { refreshDealData() NSTimer.scheduledTimerWithTimeInterval(60.0, target: self, selector: Selector("runCountDownFunction:

我需要每分钟都运行的函数。 所以我决定使用NSTimer.scheduledTimerWithTimeInterval函数

这是我的密码

override func viewWillAppear(animated: Bool) {
        refreshDealData()
        NSTimer.scheduledTimerWithTimeInterval(60.0, target: self, selector: Selector("runCountDownFunction:"), userInfo: nil, repeats: true)
    }

func runCountDownFunction()
    {
        NSLog("hello World")
        self.countDownTime = self.now.timeIntervalSinceDate(self.dealDateAndTime)
        self.duration = Int(self.countDownTime)
        self.duration = abs(self.duration)

        var countDownHours = self.duration / 3600
        var countDownMinutes = (self.duration % 3600) / 60
        var countDownSeconds = (self.duration % 3600) % 60
        var countDownDays = countDownHours / 24
        var countDownHoursDisplay = countDownHours % 24
        self.mCountDown.text = "\(countDownDays)D \(countDownHoursDisplay)H \(countDownMinutes)M"

    }
但是我在1分钟后从viewwillbeen得到这个错误

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[RockStarTable.DealInsideViewController runCountDownFunction:]: unrecognized selector sent to instance 0x7f91ed8c8000'
有人知道如何解决这个问题吗? 谢谢

您的选择器是
“runCountDownFunction:”
。冒号是有意义的;这意味着此方法只接受一个参数。因此,您必须使您的方法接受一个参数。如下所示声明您的方法:

func runCountDownFunction(timer:NSTimer) {
现在,它的签名与您创建计时器时给出的选择器匹配。

您的选择器是
“runCountDownFunction:”
。冒号是有意义的;这意味着此方法只接受一个参数。因此,您必须使您的方法接受一个参数。如下所示声明您的方法:

func runCountDownFunction(timer:NSTimer) {
现在,它的签名与您创建计时器时给出的选择器匹配。

您的选择器是
“runCountDownFunction:”
。冒号是有意义的;这意味着此方法只接受一个参数。因此,您必须使您的方法接受一个参数。如下所示声明您的方法:

func runCountDownFunction(timer:NSTimer) {
现在,它的签名与您创建计时器时给出的选择器匹配。

您的选择器是
“runCountDownFunction:”
。冒号是有意义的;这意味着此方法只接受一个参数。因此,您必须使您的方法接受一个参数。如下所示声明您的方法:

func runCountDownFunction(timer:NSTimer) {

现在,它的签名与您创建计时器时给出的选择器匹配。

我的书解释了选择器必须如何形成以及它们与方法签名的关系:我的书解释了选择器必须如何形成以及它们与方法签名的关系:我的书解释了选择器必须如何形成以及它们与方法签名的关系:我的书本书解释了选择器必须如何形成以及它们与方法签名的关系: