Reputation:
I'm having some problem with my app. The message Thread 1: Signal SIGABRT keeps popping up when I press a UIButton
.
Here's my code:
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.
}
}
I checked the debugger, and it keeps saying that I sent an unrecognized selector sent to instance 0x7fa7baebc4c0. Can someone help me figure out what this means?
Upvotes: 0
Views: 37
Reputation: 3105
You are trying to use a method called "update" when you create your timer but your code (at least the portion you shared) does NOT have an update function.
@IBAction func hackButton(sender: AnyObject) {
let timer = NSTimer.scheduledTimerWithTimeInterval(1, target: self, selector: "update", userInfo: nil, repeats: false)
}
func update() { // do your updates here
}
Upvotes: 1
Reputation: 1426
That's because timer == 1
doesn't mean anything. The function update will be called by the timer and from there you can yourself keep a counter and increment it.
Upvotes: 1