ios - 点击按钮时无法识别的选择器错误

标签 ios swift unrecognized-selector

我的应用程序出现问题。当我按下 UIButton 时,消息 Thread 1: Signal SIGABRT 不断弹出。

这是我的代码:

import UIKit

class ViewController: UIViewController {
@IBOutlet var instructions: UILabel!


@IBOutlet var lockStatus: UIImageView!

@IBAction func hackButton(sender: AnyObject) {

    let timer = NSTimer.scheduledTimerWithTimeInterval(1, target: self, selector: "update", userInfo: nil, repeats: false)


        while(timer == 1){instructions.text = "loading"}
        while(timer == 2){instructions.text = "loading."}
    while(timer == 3) {instructions.text = "loading.."}
        while(timer == 4){instructions.text = "loading..."}
        while(timer == 5) {instructions.text = "hack successful!"
            lockStatus.image = UIImage(named: "unlocked.png")
            timer.invalidate()

    }

    }



override func viewDidLoad() {

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

override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated.
}


}

我检查了调试器,它一直说我向实例 0x7fa7baebc4c0 发送了一个无法识别的选择器。谁能帮我弄清楚这是什么意思?

最佳答案

您在创建计时器时尝试使用一种称为“更新”的方法,但您的代码(至少您共享的部分)没有更新功能。

@IBAction func hackButton(sender: AnyObject) {
    let timer = NSTimer.scheduledTimerWithTimeInterval(1, target: self, selector: "update", userInfo: nil, repeats: false)
}

func update() {   // do your updates here 
}

关于ios - 点击按钮时无法识别的选择器错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33983506/

相关文章:

iOS 版本 : This build is invalid in iTunes connect

c++ - 在桥接头文件中导入头文件导致的Swift编译错误

ios - 如何获取kCVPixelFormatType_DepthFloat16的值(半点 float )?

ios - Objective-C 属性 getter 抛出异常 'Unrecognized selector sent to instance'

ios - Swift 2,无法识别的选择器发送到 UIAlertController 的实例

ios - 屏幕外的界面生成器位置

ios - 如何在 swift 中避免循环 segues

ios - 当我点击 UIBarButtonItem 时它会一直高亮

ios - 从一个类调用另一个类中的函数 - swift

ios - Braintree SDK 的 Xcode Swift 错误