dimanche 1 février 2015

'NSString' is not a subtype of 'UILAbel' in Swift View Controller

I'm currently reading the book, Beginning iPhone Development with Swift and having some trouble in the third chapter's exercise. It basically has you created two buttons (both linked to the same action) and a label that has its text change depending on which button you press. I've followed the example code exactly but still get the error NSString' is not a subtype of 'UILAbel over my last line within the function. All three UI elements are linked as they should but don't know what its not working.



class ViewController: UIViewController {
@IBOutlet weak var statusLabel: UILabel!

@IBAction func buttonPressed(sender: UIButton) {
let title = sender.titleForState(.Normal)!
let plainText = "\(title) button pressed"
statusLabel = plainText
}
}



Aucun commentaire:

Enregistrer un commentaire